STL rework
- fixed lots of bugs - overlay libraries work correctly and reliably - the STL is an overlay library - examples updated
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
export Y := \f.(\x.f (x x))(\x.f (x x))
|
||||
|
||||
export loop $r on (..$parameters) with ...$tail =0x5p129=> Y (\$r.
|
||||
bind_names (..$parameters) (...$tail)
|
||||
) ..$parameters
|
||||
|
||||
-- bind each of the names in the first argument as a parameter for the second argument
|
||||
bind_names ($name ..$rest) $payload =0x1p250=> \$name. bind_names (..$rest) $payload
|
||||
bind_names () (...$payload) =0x1p250=> ...$payload
|
||||
|
||||
export ...$prefix $ ...$suffix:1 =0x1p39=> ...$prefix (...$suffix)
|
||||
export ...$prefix |> $fn ..$suffix:1 =0x2p32=> $fn (...$prefix) ..$suffix
|
||||
|
||||
export (...$argv) => ...$body =0x2p129=> (bind_names (...$argv) (...$body))
|
||||
$name => ...$body =0x1p129=> (\$name. ...$body)
|
||||
@@ -1,41 +0,0 @@
|
||||
import option
|
||||
import super::fn::*
|
||||
|
||||
pair := \a.\b. \f. f a b
|
||||
|
||||
-- Constructors
|
||||
|
||||
export cons := \hd.\tl. option::some (pair hd tl)
|
||||
export end := option::none
|
||||
|
||||
export pop := \list.\default.\f.list default \cons.cons f
|
||||
|
||||
-- Operators
|
||||
|
||||
export reduce := \list.\acc.\f. (
|
||||
loop r on (list acc) with
|
||||
pop list acc \head.\tail. r tail (f acc head)
|
||||
)
|
||||
|
||||
export map := \list.\f. (
|
||||
loop r on (list) with
|
||||
pop list end \head.\tail. cons (f head) (r tail)
|
||||
)
|
||||
|
||||
export skip := \list.\n. (
|
||||
loop r on (list n) with
|
||||
if n == 0 then list
|
||||
else pop list end \head.\tail. r tail (n - 1)
|
||||
)
|
||||
|
||||
export take := \list.\n. (
|
||||
loop r on (list n) with
|
||||
if n == 0 then end
|
||||
else pop list end \head.\tail. cons head $ r tail $ n - 1
|
||||
)
|
||||
|
||||
new[...$item, ...$rest:1] =0x2p84=> (cons (...$item) new[...$rest])
|
||||
new[...$end] =0x1p84=> (cons (...$end) end)
|
||||
new[] =0x1p84=> end
|
||||
|
||||
export ::(new)
|
||||
@@ -1,6 +1,4 @@
|
||||
import std::(to_string, print)
|
||||
import super::list
|
||||
import fn::*
|
||||
import std::(proc::*, io::print, to_string)
|
||||
|
||||
export main := do{
|
||||
let foo = list::new[1, 2, 3, 4, 5, 6];
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export some := \v. \d.\f. f v
|
||||
export none := \d.\f. d
|
||||
|
||||
export map := \option.\f. option none f
|
||||
export flatten := \option. option none \opt. opt
|
||||
export flatmap := \option.\f. option none \opt. map opt f
|
||||
Reference in New Issue
Block a user