diff --git a/julia/.gitignore b/julia/.gitignore index ff2c26d2e4d615caaa3673e39cc360fc52dc9481..fbb41be7f37b965a0d9478f2c312d3204d3a6177 100644 --- a/julia/.gitignore +++ b/julia/.gitignore @@ -1,2 +1,2 @@ *.tar.gz -julia-1.0.4 +julia-* diff --git a/julia/Makefile b/julia/Makefile index 8b65272594dc22a837323b2f6e9150adf2be4d0e..2020fa8c58f72ee03346e18c316c4bfdc7bc2c3c 100644 --- a/julia/Makefile +++ b/julia/Makefile @@ -1,14 +1,16 @@ .PHONY: run -run: julia-1.0.4/bin/julia +VERSION=1.2.0 + +run: julia-$(VERSION)/bin/julia $< run.jl -shell: julia-1.0.4/bin/julia +shell: $(VERSION)/bin/julia $< -julia-1.0.4/bin/julia: julia-1.0.4-linux-x86_64.tar.gz +julia-%/bin/julia: julia-%-linux-x86_64.tar.gz tar xzf $< $@ -e 'using Pkg; Pkg.add("BenchmarkTools"); Pkg.add("StatProfilerHTML")' touch $@ -julia-1.0.4-linux-x86_64.tar.gz: - wget https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.4-linux-x86_64.tar.gz +julia-%-linux-x86_64.tar.gz: + wget https://julialang-s3.julialang.org/bin/linux/x64/`echo $@ | grep -E -o [0-9]+[.][0-9]+`/$@ diff --git a/julia/run.jl b/julia/run.jl index 3728a8fd904b525f62928f11252efcc8ea4eca79..0278924ba6fc235ee416f29925dab1820bcb4604 100644 --- a/julia/run.jl +++ b/julia/run.jl @@ -1,6 +1,7 @@ """Template programming is a sort of metaprogramming where you fill in the blanks, but most parts of the code are very similar.""" +# Problem1 for (name,op) in [(:add, :+), (:sub, :-), (:mul, :*)] # Create a function that is named for example add and returns the # sum of its two arguments @@ -14,19 +15,20 @@ end at runtime, but it is so similar to template programming that you could try to delete a function instead.""" -module Problem1 +module Problem2 f(a::Int) = 1 f(a::Any) = 2 end # TODO: Delete the method f(a::Int) so that f(1) returns the value 2 instead of 1 -@assert 2 == Problem1.f(1) +@assert 2 == Problem2.f(1) +# Problem3 # TODO: Make an until block for Julia, similar to do {} while (cond); in C # # Make sure that any assertions and error-messages refer to lines in the original code. # Hint: You can access a hidden input __source__ in a macro and use that to replace source information. # By having the macro in a separate file, you can check source locations that match dowhile.jl and replace them with __source__. -include("dowhile.jl") +include("dowhile.jl") # Modify the macro in dowhile.jl function testDoWhile() local a = 5 @doWhile begin diff --git a/profiling/Makefile b/profiling/Makefile index 97d95518bec953f38da65b7c058b14c9fe3117a1..2fb559cf1b8398f1d2ca6e5d002943c43bb5b02c 100644 --- a/profiling/Makefile +++ b/profiling/Makefile @@ -1,7 +1,9 @@ .PHONY: run -run: ../julia/julia-1.0.4/bin/julia +VERSION=1.2.0 + +run: ../julia/julia-$(VERSION)/bin/julia $< test.jl -../julia/julia-1.0.4/bin/julia: - $(MAKE) -C ../julia julia-1.0.4/bin/julia +../julia/julia-$(VERSION)/bin/julia: + $(MAKE) -C ../julia julia-$(VERSION)/bin/julia