File: nested-closures0.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 (12 lines) | stat: -rw-r--r-- 395 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
-- A local function with a free variable that itself is a function that closes
-- over its own local variables, i.e., a closure inside a closure environment.
-- ==
-- input { 12 } output { 17 }

def main (x : i32) =
  let f = let b = 2 in
          let g = let a = 1 in
                  let h = \(x:i32) -> x+a
                  in \(z:i32) -> h b + z
          in \(y:i32) -> g y + b
  in f x