pre-recording backup

This commit is contained in:
2023-05-17 03:49:26 +01:00
parent 126494c63f
commit 330ddbe399
29 changed files with 404 additions and 195 deletions

View File

@@ -0,0 +1,15 @@
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 =0x1p34=> ...$prefix (...$suffix)
export ...$prefix |> $fn ..$suffix:1 =0x2p32=> $fn (...$prefix) ..$suffix
export (...$argv) => ...$body =0x2p129=> (bind_names (...$argv) (...$body))
$name => ...$body =0x1p129=> (\$name. ...$body)

View File

@@ -2,10 +2,13 @@ import std::(parse_float, to_string)
import std::(readline, print)
export main := do{
cps print "left operand: ";
cps data = readline;
let a = parse_float data;
cps print "operator: ";
cps op = readline;
cps print ("\"" ++ op ++ "\"\n");
cps print ("you selected \"" ++ op ++ "\"\n");
cps print "right operand: ";
cps data = readline;
let b = parse_float data;
let result = (
@@ -13,8 +16,8 @@ export main := do{
else if op == "-" then a - b
else if op == "*" then a * b
else if op == "/" then a / b
else "Unsupported operation" -- dynamically typed shenanigans
else (panic "Unsupported operation")
);
cps print (to_string result ++ "\n");
cps print ("Result: " ++ to_string result ++ "\n");
0
}

View File

@@ -1,15 +1,15 @@
export Y := \f.(\x.f (x x))(\x.f (x x))
export loop $r on (...$parameters) with ...$tail =0x5p512=> Y (\$r.
bind_names (...$parameters) (...$tail)
) ...$parameters
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 =0x2p1000=> \$name. bind_names (..$rest) $payload
bind_names () (...$payload) =0x1p1000=> ...$payload
bind_names ($name ..$rest) $payload =0x1p250=> \$name. bind_names (..$rest) $payload
bind_names () (...$payload) =0x1p250=> ...$payload
export ...$prefix $ ...$suffix:1 =0x1p130=> ...$prefix (...$suffix)
export ...$prefix |> $fn ..$suffix:1 =0x2p130=> $fn (...$prefix) ..$suffix
export ...$prefix $ ...$suffix:1 =0x1p34=> ...$prefix (...$suffix)
export ...$prefix |> $fn ..$suffix:1 =0x2p32=> $fn (...$prefix) ..$suffix
export (...$argv) => ...$body =0x2p512=> (bind_names (...$argv) (...$body))
$name => ...$body =0x1p512=> (\$name. ...$body)
export (...$argv) => ...$body =0x2p129=> (bind_names (...$argv) (...$body))
$name => ...$body =0x1p129=> (\$name. ...$body)

View File

@@ -34,8 +34,8 @@ export take := \list.\n. (
else pop list end \head.\tail. cons head $ r tail $ n - 1
)
new[...$item, ...$rest:1] =0x2p333=> (cons (...$item) new[...$rest])
new[...$end] =0x1p333=> (cons (...$end) end)
new[] =0x1p333=> end
new[...$item, ...$rest:1] =0x2p84=> (cons (...$item) new[...$rest])
new[...$end] =0x1p84=> (cons (...$end) end)
new[] =0x1p84=> end
export ::(new)

View File

@@ -1,15 +1,15 @@
export Y := \f.(\x.f (x x))(\x.f (x x))
export loop $r on (...$parameters) with ...$tail =0x5p512=> Y (\$r.
bind_names (...$parameters) (...$tail)
) ...$parameters
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 =0x2p1000=> \$name. bind_names (..$rest) $payload
bind_names () (...$payload) =0x1p1000=> ...$payload
bind_names ($name ..$rest) $payload =0x1p250=> \$name. bind_names (..$rest) $payload
bind_names () (...$payload) =0x1p250=> ...$payload
export ...$prefix $ ...$suffix:1 =0x1p130=> ...$prefix (...$suffix)
export ...$prefix |> $fn ..$suffix:1 =0x2p130=> $fn (...$prefix) ..$suffix
export ...$prefix $ ...$suffix:1 =0x1p34=> ...$prefix (...$suffix)
export ...$prefix |> $fn ..$suffix:1 =0x2p32=> $fn (...$prefix) ..$suffix
export (...$argv) => ...$body =0x2p512=> (bind_names (...$argv) (...$body))
$name => ...$body =0x1p512=> (\$name. ...$body)
export (...$argv) => ...$body =0x2p129=> (bind_names (...$argv) (...$body))
$name => ...$body =0x1p129=> (\$name. ...$body)

View File

@@ -41,8 +41,8 @@ export get := \list.\n. (
else r tail (n - 1)
)
new[...$item, ...$rest:1] =0x2p333=> (cons (...$item) new[...$rest])
new[...$end] =0x1p333=> (cons (...$end) end)
new[] =0x1p333=> end
new[...$item, ...$rest:1] =0x2p84=> (cons (...$item) new[...$rest])
new[...$end] =0x1p84=> (cons (...$end) end)
new[] =0x1p84=> end
export ::(new)

View File

@@ -2,6 +2,7 @@ import list
import map
import option
import fn::*
import std::(print, to_string)
export main := do{
let foo = map::new[
@@ -10,13 +11,8 @@ export main := do{
"baz" = 3,
"bar" = 4
];
map::get foo "bar"
|> option::unwrap
}
--[
export main := do{
let foo = list::new[1, 2, 3];
map::fst foo
}
]--
let num = map::get foo "bar"
|> option::unwrap;
cps print (to_string num ++ "\n");
0
}

View File

@@ -16,9 +16,6 @@ export snd := \l. (
(panic "2 elements expected")
\x.x
)
export print_pair := \l. (
to_string (fst l) ++ " = " ++ to_string (snd l)
)
-- constructors
@@ -51,7 +48,7 @@ export del := \m.\k. (
)
-- remove all occurrences of a key
export clear := \m.\k. (
export delall := \m.\k. (
loop r on (m) with
list::pop m list::end \head.\tail.
if (fst head) == k then r tail
@@ -65,10 +62,18 @@ export set := \m.\k.\v. (
|> add k v
)
new[...$tail:2, ...$key = ...$value:1] =0x2p333=> (
-- ensure that there's only one instance of each key in the map
export normalize := \m. do{
let normal = empty
loop r on (m normal) with
list::pop m normal \head.\tail.
r tail $ set normal (fst head) (snd head)
}
new[...$tail:2, ...$key = ...$value:1] =0x2p84=> (
set new[...$tail] (...$key) (...$value)
)
new[...$key = ...$value:1] =0x1p333=> (add empty (...$key) (...$value))
new[] =0x1p333=> empty
new[...$key = ...$value:1] =0x1p84=> (add empty (...$key) (...$value))
new[] =0x1p84=> empty
export ::(new)

View File

@@ -0,0 +1,3 @@
export main := do{
}