Skip to content

Commit

Permalink
Add example for Map on a Vector
Browse files Browse the repository at this point in the history
  • Loading branch information
vidsinghal committed Feb 3, 2024
1 parent 47b5c65 commit 2d83d67
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gibbon-compiler/examples/tail_recursion/MapOnVector.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module MapOnVector where

import Gibbon.Vector

add1 :: Int -> Int
add1 x = x + 1


gibbon_main =
let n = sizeParam
ls :: Vector Int
ls = generate sizeParam (\i -> n-i)
-- generate_loop is the recursive function to look at, if it is tail_recursive or not.
ls' = iterate (map add1 ls)
--_ = printVec (\i -> printint i) ls'
in (ls,ls')

0 comments on commit 2d83d67

Please sign in to comment.