mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 01:44:37 +00:00
16 lines
278 B
Nim
16 lines
278 B
Nim
type
|
|
TBinOp*[T] = proc (x,y: T): bool
|
|
|
|
THeap*[T] = object
|
|
cmp*: TBinOp[T]
|
|
|
|
proc less*[T](x,y: T): bool =
|
|
x < y
|
|
|
|
proc initHeap*[T](cmp: TBinOp[T]): THeap[T] =
|
|
result.cmp = cmp
|
|
|
|
when isMainModule:
|
|
var h = initHeap[int](less[int])
|
|
|
|
echo h.cmp(2,3) |