Skip to content

Commit

Permalink
💚 🎉 test 11 passing
Browse files Browse the repository at this point in the history
  • Loading branch information
laendoor committed Dec 15, 2021
1 parent 9230178 commit 5598993
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bin/flecha_foones
Git LFS file not shown
5 changes: 4 additions & 1 deletion test/mam.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ function mam_test() {
}

@test "mam::test11" {
skip
mam_test "test/mamarracho/test11"
}

@test "mam::test11.1" {
mam_test "test/mamarracho/test11.1"
}

@test "mam::test12" {
skip
mam_test "test/mamarracho/test12"
Expand Down
1 change: 1 addition & 0 deletions test/mamarracho/test11.1.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TEST 32|O
62 changes: 62 additions & 0 deletions test/mamarracho/test11.1.flecha
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
def test numero fn valor =
unsafePrintChar 'T';
unsafePrintChar 'E';
unsafePrintChar 'S';
unsafePrintChar 'T';
unsafePrintChar ' ';
unsafePrintInt numero;
unsafePrintChar '|';
fn valor;
unsafePrintChar '\n'

def zero z f = z
def suc n z f = f (n z f)
def foldn z f n = n z f
def const x y = x

def n0 = zero
def n1 = suc n0
def n2 = suc n1
def n3 = suc n2

def compose f g x = f (g x)

def true x y = x
def false x y = y
def cond x y z = x y z

def nil z f = z
def cons x xs z f = f x (xs z f)

def pair x y f = f x y
def fst p = p true
def snd p = p false

def foldr z f lst = lst z f
def null = foldr true (compose const const false)

def tail lst =
snd (foldr (pair nil nil)
(\ x r -> pair (cons x (fst r)) (fst r))
lst)

def length lst = length_ lst '_'
def length_ lst =
cond (null lst)
(\ u -> n0)
(\ u -> suc (length_ (tail lst) '_'))

def printNat n =
foldn (\ u -> unsafePrintChar 'O')
(\ r u -> (unsafePrintChar 'S'; r u))
n
'_'

def main =
let l0 = nil in
let l1 = cons n1 nil in
let l2 = cons n1 (cons n2 nil) in
let l3 = cons n1 (cons n2 (cons n3 nil)) in
let ll = cons l3 (cons l2 (cons l1 nil)) in
test 32 printNat (length l0)

0 comments on commit 5598993

Please sign in to comment.