Advertisement
xxar3s

Untitled

Oct 31st, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.48 KB | None | 0 0
  1. // 1. možnosť:
  2.  
  3. let foo n =
  4.     [1 .. n]
  5.     |> List.choose
  6.         (fun x ->
  7.             match x * 2 + 3 with i when i > 30 -> Some i | _ -> None)
  8.  
  9. // 2. možnosť:
  10.  
  11. let bar n =
  12.     let rec my acc = function
  13.     | 0 -> acc
  14.     | i ->
  15.         let x = i * 2 + 3
  16.         my (if x > 30 then x :: acc else acc) <| i - 1
  17.     my [] n
  18.  
  19. // 3. možnosť:
  20.  
  21. let baz n = seq { for i in 1 .. n do
  22.                     let i = i * 2 + 3
  23.                     if i > 30 then yield i }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement