Guest User

Subst Tree Using Param into Lambda Body

a guest
Dec 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.34 KB | None | 0 0
  1. macro constrain*[T](problem: Problem[T], input: untyped): untyped =
  2.     var stmts = newStmtList()
  3.  
  4.     for i in 0..<input.len:
  5.         let (vars, tree) = parseVars(input[i])
  6.        
  7.         stmts.add quote do: addConstraint(
  8.             `problem`,
  9.             proc(x: varargs[T]): bool = `tree`,
  10.             `vars`)
  11.  
  12.     return stmts
Advertisement
Add Comment
Please, Sign In to add comment