diff options
Diffstat (limited to 'lambda-to-mu.mu')
-rw-r--r-- | lambda-to-mu.mu | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/lambda-to-mu.mu b/lambda-to-mu.mu index 0ad61e51..4feb5ac9 100644 --- a/lambda-to-mu.mu +++ b/lambda-to-mu.mu @@ -10,51 +10,58 @@ result <- add a t1] ] ] -container cell [ - first:address:cell-value - rest:address:cell +def lambda-to-mu in:address:array:character -> out:address:array:character [ + local-scope + load-ingredients + out <- copy 0 + tmp:address:cell <- parse in + out <- to-mu tmp ] -exclusive-container cell-value [ +exclusive-container cell [ atom:address:array:character - cell:address:cell + pair:pair +] + +container pair [ + first:address:cell + rest:address:cell ] def new-atom name:address:array:character -> result:address:cell [ local-scope load-ingredients - cv:address:cell-value <- new cell-value:type - *cv <- merge 0/tag:atom, name result <- new cell:type - *result <- merge cv, 0/rest + *result <- merge 0/tag:atom, name ] def new-cell a:address:cell, b:address:cell -> result:address:cell [ local-scope load-ingredients - cv:address:cell-value <- new cell-value:type - *cv <- merge 1/tag:cell, a result <- new cell:type - *result <- merge cv/first, b/rest + *result <- merge 1/tag:pair, a/first, b/rest ] def is-atom? x:address:cell -> result:boolean [ + local-scope + load-ingredients reply-unless x, 0/false - cv:address:cell-value <- get *x, first:offset - reply-unless cv, 0/false - _, result <- maybe-convert *cv, atom:variant + _, result <- maybe-convert *x, atom:variant ] def is-cell? x:address:cell -> result:boolean [ + local-scope + load-ingredients reply-unless x, 0/false - cv:address:cell-value <- get *x, first:offset - reply-unless cv, 0/false - _, result <- maybe-convert *cv, atom:variant + _, result <- maybe-convert *x, pair:variant ] -def lambda-to-mu in:address:array:character -> out:address:array:character [ +scenario atom-operations [ local-scope - load-ingredients - tmp <- parse in - out <- to-mu tmp + s:address:array:character <- new [a] + x:address:cell <- new-atom s + 10:boolean/raw <- is-atom? x + memory-should-contain [ + 10 <- 1 + ] ] |