Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,20 @@
let rec brk p lst =
match lst with
| [] -> (lst, lst)
| x::xs ->
if p x
then ([], lst)
else
let (ys, zs) = brk p xs
(x::ys, zs)
let span p lst = brk (not << p) lst
let rec groupBy eq lst =
match lst with
| [] -> []
| x::xs ->
let (ys,zs) = span (eq x) xs
(x::ys)::groupBy eq zs
let group lst : list<list<'a>> when 'a : equality = groupBy (=) lst

View file

@ -0,0 +1,10 @@
let lookAndSay =
let describe (xs: char list) =
List.append (List.ofSeq <| (List.length xs).ToString()) [List.head xs]
let next xs = List.collect describe (group xs)
let toStr xs = String (Array.ofList xs)
Seq.map toStr <| Seq.unfold (fun xs -> Some (xs, next xs)) ['1']
let getNthLookAndSay n = Seq.nth n lookAndSay
Seq.take 10 lookAndSay