File: Test3

package info (click to toggle)
omake 0.10.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,076 kB
  • sloc: ml: 49,729; ansic: 5,163; makefile: 688; sh: 110
file content (33 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# Nested curried functions
#
curry.f(x) =
   private.x = $x
   curry.g(y) =
      private.y = $y
      curry.h(z) =
         add($x, $y, $z)

errors = false

# Partial applications are not allowed
try
   i = $(f 0)
   eprintln($"Error: partial application f(0) was allowed, result $i")
   errors = true
   export
default
   println($"f(0) failed [SUCCESS]")
   # Supposed to fail

# Should take 3 arguments exactly
i = $(f 10, 20, 30)
if $(not $(equal $i, 60))
    eprintln($"f(10, 20, 30) evaluates to $i, expected 60 [ERROR]")
    errors = true
    export
else
    println($"f(10, 20, 30) = 60 [SUCCESS]")

if $(errors)
    exit 1