<Query Kind="FSharpProgram" />

let a = [1; 2; 3] // 1::[2;3] 1::2::[3] 1::2::3::[] [1]@[2;3]
printfn "a = %A" a

let head1::tail1 = [1;2;3]
printfn "head1 = %A, tail1 = %A" head1 tail1

let head2 = [1;2;3].Head
let tail2 = [1;2;3].Tail
printfn "head2 = %A, tail2 = %A" head2 tail2

let head3 = List.head [1;2;3]
let tail3 = List.tail [1;2;3]
printfn "head3 = %A, tail3 = %A" head3 tail3

let b = [ for x in 10..10..30 do yield x+1 ]
printfn "b = %A" b

let c = [ for x in 10..10..30 do yield [x+1; x+2; x+3] ]
printfn "c = %A" c

let d = [ for x in 10..10..30 do yield! [x+1; x+2; x+3] ]
printfn "d = %A" d

printf "... "
for x in [10; 20; 30] do
    printf "%d " x
printfn ""

let e = [10]
printfn "e = %A" e

let f = List.length [10; 20; 30] // [10; 20; 30].Length
printfn "f = %A" f

let g = List.map (fun x -> x + 1) [10; 20; 30]
printfn "g = %A" g

let h = List.fold (fun s x -> s + x) 0 [10; 20; 30]
printfn "h = %A" h

let i = List.sum [10; 20; 30]
printfn "i = %A" i

let j = List.concat (seq [[11; 12; 13]; [21; 22; 23]; [31; 32; 33]])
printfn "j = %A" j

let k = List.collect (fun x -> [x+1; x+2; x+3]) [10; 20; 30]
printfn "k = %A" k

// ---

let inc1 x = x + 1 // int -> int

let listinc1 = List.map inc1

let g1 = listinc1 [10; 20; 30]
printfn "g1 = %A" g1

let inc2 x = [ x+1 ] // int -> list<int> = int list

let listinc2 = List.collect inc2

let g2 = listinc2 [10; 20; 30]
printfn "g2 = %A" g2

// ---

let l = List.item 2 [10; 20; 30] // order
printfn "l = %A" l

let n = List.empty<int> // [] is generic!
printfn "n = %A" n

let o = List.filter (fun x -> x % 4 <> 0) [10; 20; 30] // where
printfn "o = %A" o

let p = List.replicate 3 100
printfn "p = %A" p

let q = List.init 3 (fun i -> (i+1)*100)
printfn "q = %A" q

let z = List.zip [1; 2; 3] [10; 20; 30] // must have same len
printfn "z = %A" z