Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Comma-quibbling/F-Sharp/comma-quibbling-1.fs
Normal file
14
Task/Comma-quibbling/F-Sharp/comma-quibbling-1.fs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
let quibble list =
|
||||
let rec inner = function
|
||||
| [] -> ""
|
||||
| [x] -> x
|
||||
| [x;y] -> sprintf "%s and %s" x y
|
||||
| h::t -> sprintf "%s, %s" h (inner t)
|
||||
sprintf "{%s}" (inner list)
|
||||
|
||||
// test interactively
|
||||
quibble []
|
||||
quibble ["ABC"]
|
||||
quibble ["ABC"; "DEF"]
|
||||
quibble ["ABC"; "DEF"; "G"]
|
||||
quibble ["ABC"; "DEF"; "G"; "H"]
|
||||
10
Task/Comma-quibbling/F-Sharp/comma-quibbling-2.fs
Normal file
10
Task/Comma-quibbling/F-Sharp/comma-quibbling-2.fs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
> quibble [];;
|
||||
val it : string = "{}"
|
||||
> quibble ["ABC"];;
|
||||
val it : string = "{ABC}"
|
||||
> quibble ["ABC"; "DEF"];;
|
||||
val it : string = "{ABC and DEF}"
|
||||
> quibble ["ABC"; "DEF"; "G"];;
|
||||
val it : string = "{ABC, DEF and G}"
|
||||
> quibble ["ABC"; "DEF"; "G"; "H"];;
|
||||
val it : string = "{ABC, DEF, G and H}"
|
||||
1
Task/Comma-quibbling/F-Sharp/comma-quibbling-3.fs
Normal file
1
Task/Comma-quibbling/F-Sharp/comma-quibbling-3.fs
Normal file
|
|
@ -0,0 +1 @@
|
|||
let quibble quibbler quibblee = Seq.zip quibblee quibbler //Sorry, just too good a line to miss, back in my Latin classes
|
||||
6
Task/Comma-quibbling/F-Sharp/comma-quibbling-4.fs
Normal file
6
Task/Comma-quibbling/F-Sharp/comma-quibbling-4.fs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
let fN n = quibble (List.mapi(fun n _->match n with 0->"" |1-> " and " |_->", ") n |> List.rev) n
|
||||
printf "{"; fN ["ABC"; "DEF"; "G"; "H"] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
|
||||
printf "{"; fN ["ABC"; "DEF"; "G"] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
|
||||
printf "{"; fN ["ABC"; "DEF"] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
|
||||
printf "{"; fN ["ABC"] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
|
||||
printf "{"; fN [] |> Seq.iter(fun(n,g)->printf "%s%s" n g); printfn"}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue