diff --git a/gibbon-compiler/examples/test_iterate.hs b/gibbon-compiler/examples/test_iterate.hs new file mode 100644 index 000000000..8da932094 --- /dev/null +++ b/gibbon-compiler/examples/test_iterate.hs @@ -0,0 +1,29 @@ + + +data List = Cons Int List | Nil + +addOneList :: List -> List +addOneList lst = case lst of + Nil -> Nil + Cons x rst -> let newVal = iterate (addOne x) + newRst = addOneList rst + in Cons newVal newRst + + +length :: List -> Int +length lst = case lst of + Nil -> 0 + Cons x rst -> 1 + length rst + +addOne :: Int -> Int +addOne x = x + 1 + + +mkList :: Int -> List +mkList len = if len <= 0 then Nil + else Cons len (mkList (len-1)) + + + + +gibbon_main = length (addOneList (mkList 10)) diff --git a/gibbon-compiler/tests/test-gibbon-examples.yaml b/gibbon-compiler/tests/test-gibbon-examples.yaml index ff123bb0d..72ba5f4df 100644 --- a/gibbon-compiler/tests/test-gibbon-examples.yaml +++ b/gibbon-compiler/tests/test-gibbon-examples.yaml @@ -915,3 +915,6 @@ tests: answer-file: examples/layout_bench/manyFuncsGlobal.ans failing: [interp1,pointer,gibbon1, gibbon3] run-modes: ["gibbon2"] + + - name: test_iterate.hs + skip: true