File: shape-params0.fut

package info (click to toggle)
haskell-futhark 0.25.27-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,836 kB
  • sloc: haskell: 99,384; ansic: 12,821; python: 3,394; yacc: 783; javascript: 558; sh: 550; lisp: 395; makefile: 263
file content (14 lines) | stat: -rw-r--r-- 482 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- Defunctionalization should not leave the shape parameter on lifted
-- functions whose parameters do not refer to the shape, and it should
-- preserve (or introduce new shape parameters) on lifted functions
-- when necessary.
-- ==
-- input { [2,3,5,1] [6,5,2,6] } output { [8,8,7,7] }

def map2 'a 'b 'c [m] (f: a -> b -> c) (xs: [m]a) (ys: [m]b): [m]c =
  map (\(x,y) -> f x y) (zip xs ys)

def add (x: i32) (y: i32) = x + y

def main (xs: []i32) (ys: []i32) =
  map2 add xs ys