# HR F#: Sum of Odd Elements

The problem Sum of Odd Elements:

You are given a list. Return the sum of odd elements from the given list.

The solusion is basically just an invocation of the List.fold from the standard library:

```
let f arr =
arr
|> List.fold (fun s v -> if Math.Abs(v % 2) = 1 then s + v else s) 0
```

Math.Abs is required because for negative numbers % 2 returns either 0 or -1.

Why not to chat about this post? Join Telegram group Alex@Net or message on Twitter to alex_at_net. Alternatively, use the comments form below.