mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-24 16:25:25 +00:00
implemented 'koch pdf'
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
discard """
|
||||
output: '''10
|
||||
10
|
||||
10
|
||||
3
|
||||
3
|
||||
noReturn
|
||||
6
|
||||
'''
|
||||
"""
|
||||
|
||||
import future
|
||||
|
||||
proc twoParams(x: (int, int) -> int): int =
|
||||
result = x(5, 5)
|
||||
|
||||
proc oneParam(x: int -> int): int =
|
||||
x(5)
|
||||
|
||||
proc noParams(x: () -> int): int =
|
||||
result = x()
|
||||
|
||||
proc noReturn(x: () -> void) =
|
||||
x()
|
||||
|
||||
proc doWithOneAndTwo(f: (int, int) -> int): int =
|
||||
f(1,2)
|
||||
|
||||
echo twoParams(proc (a, b): auto = a + b)
|
||||
echo twoParams((x, y) => x + y)
|
||||
|
||||
echo oneParam(x => x+5)
|
||||
|
||||
echo noParams(() => 3)
|
||||
|
||||
echo doWithOneAndTwo((x, y) => x + y)
|
||||
|
||||
noReturn(() -> void => echo("noReturn"))
|
||||
|
||||
proc pass2(f: (int, int) -> int): (int) -> int =
|
||||
(x: int) -> int => f(2, x)
|
||||
|
||||
echo pass2((x, y) => x + y)(4)
|
||||
@@ -1,12 +1,12 @@
|
||||
discard """
|
||||
line: 12
|
||||
errormsg: "type mismatch: got (proc (int){.closure, gcsafe.})"
|
||||
errormsg: "type mismatch: got (proc (int){.closure, gcsafe, locks: 0.})"
|
||||
"""
|
||||
|
||||
proc ugh[T](x: T) {.closure.} =
|
||||
echo "ugha"
|
||||
|
||||
|
||||
proc takeCdecl(p: proc (x: int) {.cdecl.}) = nil
|
||||
proc takeCdecl(p: proc (x: int) {.cdecl.}) = discard
|
||||
|
||||
takeCDecl(ugh[int])
|
||||
|
||||
Reference in New Issue
Block a user