code_junkie

What does -> mean in F#?

Nov 11th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. let f : int -> int = ...
  2.  
  3. fun x y -> x + y + 1
  4.  
  5. match someList with
  6. | [] -> 0
  7. | h::t -> 1
  8.  
  9. > List.map (fun x -> x % 2 = 0) [1 .. 10];;
  10. val it : bool list
  11. = [false; true; false; true; false; true; false; true; false; true]
  12.  
  13. match x with
  14. | 1 -> dosomething
  15. | _ -> dosomethingelse
  16.  
  17. > let add a b = a + b
  18. val add: int -> int -> int
  19.  
  20. > let inc = add 1
  21. val inc: int -> int
  22.  
  23. val f : (int -> int) = fun n -> n * 2
  24.  
  25. adder n x y = n + x + y
  26.  
  27. adder 1 2 3
  28.  
  29. adder :: Int -> Int -> Int -> Int
  30.  
  31. five :: Int
  32. five = 5
  33.  
  34. add5 = adder 5
  35.  
  36. add5 :: Int -> Int -> Int
  37.  
  38. addder :: Int -> (Int -> (Int -> Int))
  39.  
  40. add5andtwomore :: Int -> (Int -> Int)
  41. add5andtwomore = adder 5
  42.  
  43. add5and7andonemore :: Int -> Int
  44. add5and7andonemore = adder 5 7
  45.  
  46. > add5and7andonemore 9
  47. => ((add5andtwomore) 7) 9
  48. => ((adder 5) 7) 9)
  49. <=> adder 5 7 9
  50.  
  51. > adder 5 7 9 = 5 + 7 + 9
  52. => 5 + 7 + 9
  53. => 21
  54.  
  55. > 5 + 7 + 9
  56. => (+ 5 (+ 7 9))
  57. => (+ 5 16)
  58. => 21
  59.  
  60. fun x y -> x + y + 1
  61.  
  62. (x, y) => x + y + 1;
  63.  
  64. Int -> Int -> Int
  65.  
  66. Int -> (Int -> Int)
  67.  
  68. F#: let f = fun x -> x*x
  69. C#: Func<int, int> f = x => x * x;
  70.  
  71. let isOne x = match x with
  72. | 1 -> true
  73. | _ -> false
Add Comment
Please, Sign In to add comment