Skip to content

Commit

Permalink
List example
Browse files Browse the repository at this point in the history
  • Loading branch information
SophieBosio committed Apr 30, 2024
1 parent 5dba64e commit d83c14a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions examples/lists.con
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
adt IntegerList = Nil | Cons Integer IntegerList .

adt Pair = Pair IntegerList Integer .

length :: IntegerList -> Integer .
length list =
rec pair ->
(case pair of
; Pair {Nil, acc} -> acc
; Pair {Cons n rest, acc} -> count rest (acc + 1))
(Pair list 0) .
4 changes: 2 additions & 2 deletions examples/test/functionApplication.con
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ plusOneTwiceGt x =*= (plusOne (plusOne x)) > x .
plus :: Integer -> Integer -> Integer .
plus x y = x + y .

plusCommutative :: Integer -> Integer -> Boolean .
plusCommutative x y =*= (plus x y) > (plus y x) .
wrongPlusCommutative :: Integer -> Integer -> Boolean .
wrongPlusCommutative x y =*= (plus x y) > (plus y x) .

0 comments on commit d83c14a

Please sign in to comment.