Julia samples (#108)

* Add julialang binary search sample

* Add unit test

* Add julialang selection sort sample

* Change julia suffix to jl

* Add recursion and quick sort with tests

* add quick sort

* Add hash table samples

* Add BFS

* Changed file names

* Add dijkstras

* Add Dijkstras test
This commit is contained in:
Massoud Afrashteh
2019-11-12 18:49:21 +03:30
committed by Aditya Bhargava
parent 30bbe9cf01
commit 9dc7611411
14 changed files with 255 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
using Test
using Suppressor
function countdown(i)
println(i)
if i <= 0
return
end
countdown(i-1)
end
result = @capture_out(countdown(10)) # return stdout result
@test result == "10
9
8
7
6
5
4
3
2
1
0
"

View File

@@ -0,0 +1,24 @@
using Test
using Suppressor
function greet2(name)
println("how are you, ",name,"?")
end
function bye()
println("ok bye!")
end
function greet(name)
println("hello, ",name,"!")
greet2(name)
println("getting ready to say bye...")
bye()
end
result = @capture_out greet("adit")
@test result == "hello, adit!
how are you, adit?
getting ready to say bye...
ok bye!
"

View File

@@ -0,0 +1,10 @@
using Test
function factorial(x)
if x == 1
return 1
end
return x * factorial(x-1)
end
@test factorial(5) == 120