Mercurial > repos > icfp2014
view code/ll.lm @ 45:75f808e60aa8
initial simulator ticker. needs print debug cleanup.
author | William Morgan <billjunk@mrgn.org> |
---|---|
date | Sat, 26 Jul 2014 23:30:55 -0700 |
parents | d5ccb66ae98b |
children |
line wrap: on
line source
#{ length <- :lst { len <- [] while: { not: (lst isInteger?)} do: { lst <- lst tail len <- len + 1 } len } reverse <- :lst { new <- [] while: { not: (lst isInteger?)} do: { new <- (lst value) | new lst <- lst tail } new } split:at <- :lst :pos { first <- [] i <- 0 while: { i < pos } do: { first <- (lst value) | first lst <- lst tail i <- i + 1 } #[(reverse: first) lst] } map <- :lst fun { new <- [] while: { not: (lst isInteger?) } do: { new <- (fun: (lst value)) | new lst <- lst tail } reverse: new } fold:with <- :lst acc :fun { while: { not: (lst isInteger?) } do: { acc <- fun: acc (lst value) lst <- lst tail } acc } filter <- :lst pred { new <- [] while: { not: (lst isInteger?) } do: { if: (pred: (lst value)) { new <- (lst value) | new } else: {} lst <- lst tail } reverse: new } flatten <- :lst { fold: lst [] with: :acc el { fold: el acc with: :iacc iel { iel | iacc } } } }