29 people like it.

FizzBuzz

add snippet tag

FizzBuzz sample

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
let fizzbuzz x =
    if x % 3 = 0 && x % 5 = 0 then
        print "fizz" ans "buzz"
    elif x % 3 = 0 then
        print "fizz"
    elif x % 5 = 0 then
        print "buzz"
    else
        print number
 
let fizzbuzz_loop n =
    List.iter fizzbuzz [1 .. n]

main

1: 
fizzbuzz_loop 100;;
val fizzbuzz : x:int -> unit

Full name: Script.fizzbuzz
val x : int
printfn "fizzbuzz"
printfn "fizz"
printfn "buzz"
printfn "%d" x
val fizzbuzz_loop : n:int -> unit

Full name: Script.fizzbuzz_loop
val n : int
Multiple items
type List<'T> =
  new : unit -> List<'T> + 2 overloads
  member Add : item:'T -> unit
  member AddRange : collection:IEnumerable<'T> -> unit
  member AsReadOnly : unit -> ReadOnlyCollection<'T>
  member BinarySearch : item:'T -> int + 2 overloads
  member Capacity : int with get, set
  member Clear : unit -> unit
  member Contains : item:'T -> bool
  member ConvertAll<'TOutput> : converter:Converter<'T, 'TOutput> -> List<'TOutput>
  member CopyTo : array:'T[] -> unit + 2 overloads
  ...
  nested type Enumerator

Full name: System.Collections.Generic.List<_>

--------------------
List() : unit
List(capacity: int) : unit
List(collection: IEnumerable<'T>) : unit
val iter : action:('T -> unit) -> list:'T list -> unit

Full name: Microsoft.FSharp.Collections.List.iter

More information

Link:http://fssnip.net/1h
Posted:13 years ago
Author:
Tags: sample