From 4a59f7aa8a5c90f547e9ab4c93ac5ef601a3a653 Mon Sep 17 00:00:00 2001 From: Daniel Olsson <danol716@student.liu.se> Date: Thu, 10 Oct 2019 11:37:48 +0200 Subject: [PATCH] Fixed first julia assignment --- julia/dowhile.jl | 5 +++-- julia/run.jl | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/julia/dowhile.jl b/julia/dowhile.jl index 6471239..00afdde 100644 --- a/julia/dowhile.jl +++ b/julia/dowhile.jl @@ -1,5 +1,5 @@ macro doWhile(block, cond) - #println("__source__ ", __source__) + # println("__source__ ", __source__) #println("cond ", cond) #println("block ", block) @@ -11,6 +11,7 @@ macro doWhile(block, cond) $(esc(block)) end end - println(res) # Should not print any lines referencing dowhile.jl + #print(__source__.line) + #println(res) # Should not print any lines referencing dowhile.jl res end diff --git a/julia/run.jl b/julia/run.jl index 20a3452..a86474d 100644 --- a/julia/run.jl +++ b/julia/run.jl @@ -8,13 +8,14 @@ end for (name,op) in [(:add, :+), (:sub, :-), (:mul, :*)] # Create a function that is named for example add and returns the # sum of its two arguments - + eval(quote + ($name)(x,y) = eval(Expr(:call, $op, x, y)) + end) end - -#@assert 3 == add(1, 2) -#@assert -1.0 == sub(1.0, 2.0) -#@assert "abc" == mul("ab", "c") +@assert 3 == add(1, 2) +@assert -1.0 == sub(1.0, 2.0) +@assert "abc" == mul("ab", "c") """Reflective programming often has to do with accessing or creating functions at runtime, but it is so similar to template programming that you could -- GitLab