fork(1) download
  1. import algorithm
  2. import future
  3.  
  4. # p converst T to S and compares it as S
  5. proc gen[S, T](list: seq[T], p: proc(a:T): S): seq[T] =
  6. list.sorted( (a, b) => system.cmp[S](a.p, b.p))
  7.  
  8. let list = @[1,2,3,4,5,6]
  9. let p = proc(i:int): bool = i mod 2 == 0
  10.  
  11. echo gen(list, p)
  12.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.nim(11, 9) Info: template/generic instantiation from here
prog.nim(6, 16) Warning: '(a; b): auto' has no type. Typeless parameters are deprecated; only allowed for 'template' [TypelessParam]
prog.nim(11, 9) Info: template/generic instantiation from here
prog.nim(6, 17) Warning: '(a; b): auto' has no type. Typeless parameters are deprecated; only allowed for 'template' [TypelessParam]
prog.nim(11, 9) Info: template/generic instantiation from here
prog.nim(6, 39) Info: template/generic instantiation from here
lib/nim/system.nim(933, 8) Error: ambiguous call; both system.==(x: bool, y: bool) and system.==(x: bool, y: bool) match for: (bool, bool)
stdout
Standard output is empty