File: polymorphic4.fut

package info (click to toggle)
haskell-futhark 0.25.32-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,236 kB
  • sloc: haskell: 100,484; ansic: 12,100; python: 3,440; yacc: 785; sh: 561; javascript: 558; lisp: 399; makefile: 272
file content (13 lines) | stat: -rw-r--r-- 453 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
-- Array of tuples polymorphism.
-- ==
-- input { 2i64 } output { [1i64,0i64] [1.0,0.0] [1i64,0i64] }

module pm (P: { type vector [n] 't val reverse [n] 't: vector [n] t -> vector [n] t }) = {
  def reverse_triple [n] 'a 'b (xs: (P.vector [n] (a,b,a))) =
    P.reverse xs
}

module m = pm { type vector [n] 't = [n]t def reverse 't (xs: []t) = xs[::-1] }

def main (x: i64) =
  unzip3 (m.reverse_triple (zip3 (iota x) (map f64.i64 (iota x)) (iota x)))