Diego Javier Zea
2015-07-31 18:46:11 UTC
Hi! I don't know how to generate parameter list of functions in order to
avoid a lot repetitive code:
julia> for (param, special) in [ (:(),:()), (:(, y),:(+ y)) ]
@eval begin
function f(x $(param), z)
x $(special) + z
end
end
end
f(1,2)
f(1,2,3)
ERROR: syntax: unexpected ,
julia> for (param, special) in [ (:(),:()), (:(y, ),:(y +)) ]
@eval begin
function f(x, $(param) z)
x + $(special) z
end
end
end
f(1,2)
f(1,2,3)
ERROR: syntax: unexpected )
julia> for (param, special) in [ (:(),:()), (:(y:(,) ),:(y :(+))) ]
@eval begin
function f(x, $(param) z)
x + $(special) z
end
end
end
f(1,2)
f(1,2,3)
ERROR: syntax: unexpected ,
Best,
avoid a lot repetitive code:
julia> for (param, special) in [ (:(),:()), (:(, y),:(+ y)) ]
@eval begin
function f(x $(param), z)
x $(special) + z
end
end
end
f(1,2)
f(1,2,3)
ERROR: syntax: unexpected ,
julia> for (param, special) in [ (:(),:()), (:(y, ),:(y +)) ]
@eval begin
function f(x, $(param) z)
x + $(special) z
end
end
end
f(1,2)
f(1,2,3)
ERROR: syntax: unexpected )
julia> for (param, special) in [ (:(),:()), (:(y:(,) ),:(y :(+))) ]
@eval begin
function f(x, $(param) z)
x + $(special) z
end
end
end
f(1,2)
f(1,2,3)
ERROR: syntax: unexpected ,
Best,