├── Chapter01 ├── args.jl ├── hello.jl ├── ijulia_example.jl ├── isinteractive.jl └── main.jl ├── Chapter02 ├── arrays.jl ├── constants.jl ├── dates.jl ├── formatting.jl ├── regexp.jl ├── scope.jl └── strings_arrays.jl ├── Chapter03 ├── anonymous.jl ├── arguments.jl ├── first_class.jl ├── functions101.jl ├── generic_functions.jl └── map_filters.jl ├── Chapter04 ├── conditional.jl ├── errors.jl ├── file1.txt ├── repetitions.jl ├── scope.jl └── tasks.jl ├── Chapter05 ├── dicts.jl ├── matrices.jl ├── results_words1.txt ├── results_words2.txt ├── sets.jl ├── tuples.jl ├── word_frequency.jl ├── words1.txt └── words2.txt ├── Chapter06 ├── conversions.jl ├── file1.jl ├── file2.jl ├── inner_constructors.jl ├── modules.jl ├── parametric.jl ├── temperature_converter.jl ├── type_hierarchy.jl ├── unions.jl ├── user_defined.jl └── using_module.jl ├── Chapter07 ├── built_in_macros.jl ├── eval.jl ├── expressions.jl ├── macros.jl └── reflection.jl ├── Chapter08 ├── 495B2210 ├── csv_files.jl ├── dataframes.jl ├── defs.jl ├── echoserver.jl ├── example.dat ├── example2.dat ├── functions.jl ├── instpubs.sql ├── io.jl ├── odbc.jl ├── parallel.jl ├── parallel_loops_maps.jl ├── partial.dat ├── savetuple.csv ├── tcpserver.jl ├── tuple_csv.jl └── winequality.csv ├── Chapter09 ├── array_product_benchmark.jl ├── callc.jl ├── callpy.jl ├── file1.txt ├── file2.txt ├── performance.jl ├── shell.jl ├── test.txt └── tosort.txt ├── Chapter10 ├── plots_iris.jl └── stlib.jl ├── LICENSE └── README.md /Chapter01/args.jl: -------------------------------------------------------------------------------- 1 | for arg in ARGS 2 | println(arg) 3 | end -------------------------------------------------------------------------------- /Chapter01/hello.jl: -------------------------------------------------------------------------------- 1 | println("Hello, Julia World!") 2 | -------------------------------------------------------------------------------- /Chapter01/ijulia_example.jl: -------------------------------------------------------------------------------- 1 | a = 5 2 | b = 2a^2 + 30a + 9 3 | 4 | using PyPlot 5 | x = range(0,stop=5,length=101) 6 | y = cos.(2x .+ 5) 7 | plot(x, y, linewidth=2.0, linestyle="--") 8 | title("a nice cosinus") 9 | xlabel("x axis") 10 | ylabel("y axis") 11 | -------------------------------------------------------------------------------- /Chapter01/isinteractive.jl: -------------------------------------------------------------------------------- 1 | println("Is this interactive? $(isinteractive())") -------------------------------------------------------------------------------- /Chapter01/main.jl: -------------------------------------------------------------------------------- 1 | include("hello.jl") 2 | -------------------------------------------------------------------------------- /Chapter02/arrays.jl: -------------------------------------------------------------------------------- 1 | for i in 1:2:9 2 | println(i) 3 | end #> 1 3 5 7 9 4 | 5 | typeof(1:1000) #> UnitRange{Int64} 6 | 7 | a = split("A,B,C,D",",") 8 | typeof(a) #> Array{SubString{String},1} 9 | show(a) #> SubString{String}["A","B","C","D"] 10 | 11 | arr = [100, 25, 37] 12 | arra = Any[100, 25, "ABC"] #> element type Any 13 | arr[1] #> 100 14 | arr[end] #> 37 15 | # arr[6] 16 | #> ERROR: BoundsError: attempt to access 3-element Array{Int64,1} at index [6] 17 | println(eltype(arr)) #> Int64 18 | println(length(arr)) #> 3 19 | println(ndims(arr)) #> 1 20 | println(size(arr,1)) #> 3 21 | println(size(arr)) #> (3,) 22 | 23 | arr2 = Array{Int64}(undef, 5) 24 | show(arr2) #> [1, 2, 3, 4, 5] 25 | sizehint!(arr2, 10^5) 26 | 27 | arr3 = Float64[] #> 0-element Array{Float64,1} 28 | push!(arr3, 1.0) #> 1-element Array{Float64,1} 29 | 30 | arr4 = collect(1:7) #> 7-element Array{Int64,1} 31 | show(arr4) #> [1, 2, 3, 4, 5, 6, 7] 32 | 33 | # for in loop and changing the array: 34 | da = [1,2,3,4,5] 35 | for n in da 36 | n *= 2 37 | end 38 | da #> 5-element Array{Int64,1}: 1 2 3 4 5 39 | for i in 1:length(da) 40 | da[i] *= 2 41 | end 42 | da #> 5-element Array{Int64,1}: 2 4 6 8 10 43 | 44 | arr4 = [1,2,3,4,5,6,7] #> 7-element Array{Int64,1}: [1,2,3,4,5,6,7] 45 | join(arr4, ", ") #> "1, 2, 3, 4, 5, 6, 7" 46 | arr4[1:3] # => [1, 2, 3] 47 | arr4[4:end] # => [4, 5, 6, 7] 48 | 49 | arr = [1,2,3,4,5] 50 | arr[2:4] = [8,9,10] 51 | println(arr) #> 1 8 9 10 5 52 | 53 | zeros(5) 54 | ones(4) 55 | ones(3, 2) 56 | eqa = range(0, step=10, length=5) #> 0:10:40 57 | println() 58 | show(eqa) #> 0:10:40 59 | fill!(arr, 42) #> [42, 42, 42, 42, 42] 60 | println() 61 | println(Array{Any}(undef, 4)) #> Any[#undef,#undef,#undef,#undef] 62 | 63 | v1 = rand(Int32, 5) 64 | println(v1) #> Int32[1735276173,972339632,1303377282,1493859467,-788555652] 65 | 66 | b = collect(1:7) 67 | c = [100,200,300] 68 | append!(b,c) # Now b is [1, 2, 3, 4, 5, 6, 7, 100, 200, 300] 69 | pop!(b) #> 300, b is now [1, 2, 3, 4, 5, 6, 7, 100, 200] 70 | push!(b, 42) # b is now [1, 2, 3, 4, 5, 6, 7, 100, 200, 42] 71 | popfirst!(b) #> 1, b is now [2, 3, 4, 5, 6, 7, 100, 200, 42] 72 | pushfirst!(b, 42) # b is now [1, 2, 3, 4, 5, 6, 7, 100, 200, 42] 73 | splice!(b,8) #> 100, b is now [42, 2, 3, 4, 5, 6, 7, 200, 42] 74 | in(42, b) #> true 75 | in(43, b) #> false 76 | println() 77 | println("sorting:") 78 | sort(b) #> [2,3,4,5,6,7,42,42,200], b is not changed 79 | println(b) #> [42,2,3,4,5,6,7,200,42] 80 | sort!(b) #> b is now changed to [2,3,4,5,6,7,42,42,200] 81 | println(b) #> [2,3,4,5,6,7,42,42,200] 82 | println() 83 | arr = [1, 5, 3] 84 | # looping 85 | for e in arr 86 | print("$e ") 87 | end # prints 1 5 3 88 | 89 | arr = [1, 2, 3] 90 | arr .+ 2 #> [3, 7, 5] 91 | arr * 2 #> [2, 10, 6] 92 | a1 = [1, 2, 3] 93 | a2 = [4, 5, 6] 94 | a1 .* a2 #> [4, 10, 18] 95 | 96 | using LinearAlgebra 97 | LinearAlgebra.dot(a1, a2) #> 32 98 | sum(a1 .* a2) 99 | 100 | repeat([1, 2, 3], inner = [2]) #> [1,1,2,2,3,3] 101 | 102 | a = [1,2,4,6] 103 | a1 = a 104 | show(a1) 105 | a[4] = 0 106 | show(a) #> [1,2,4,0] 107 | show(a1) #> [1,2,4,0] 108 | b = copy(a) 109 | b = deepcopy(a) 110 | 111 | a = [1,2,3] 112 | function change_array(arr) 113 | arr[2] = 25 114 | end 115 | change_array(a) 116 | println(a) #>[ 1, 25, 3] 117 | 118 | # the splat operator: 119 | arr = ['a', 'b', 'c'] 120 | show(join(arr)) #> "abc" 121 | show(string(arr)) #> "['a', 'b', 'c']" 122 | show(string(arr...)) #> "abc" -------------------------------------------------------------------------------- /Chapter02/constants.jl: -------------------------------------------------------------------------------- 1 | const GC = 6.67e-11 # gravitational constant in m3/kg s2 2 | 3 | GC = 3.14 #> Warning: redefining constant GC 4 | # GC = 10 #> ERROR: invalid redefinition of constant GC 5 | 6 | const ARR = [4,7,1] 7 | ARR[1] = 9 8 | show(ARR) #> [9,7,1] 9 | println() 10 | ARR = [1, 2, 3] #> Warning: redefining constant ARR -------------------------------------------------------------------------------- /Chapter02/dates.jl: -------------------------------------------------------------------------------- 1 | # constructing: 2 | start_time = time() 3 | # long computation 4 | time_elapsed = time() - start_time 5 | println("Time elapsed: $time_elapsed") #> 0.0009999275207519531 6 | 7 | using Dates 8 | d = Date(2018,9,1) #> 2018-09-01 9 | dt = DateTime(2018,9,1,12,30,59,1) #> 2018-09-01T12:30:59.001 10 | # accessors: 11 | year(d) 12 | month(d) 13 | week(d) 14 | day(d) 15 | # functions: 16 | isleapyear(d) 17 | dayofyear(d) 18 | monthname(d) 19 | daysinmonth(d) -------------------------------------------------------------------------------- /Chapter02/formatting.jl: -------------------------------------------------------------------------------- 1 | using Printf 2 | # d for integers: 3 | @printf("%d\n", 1e5) #> 100000 4 | x = 7.35679 5 | # f = float format, rounded if needed: 6 | @printf("x = %0.3f\n", x) #> 7.357 7 | aa = 1.5231071779744345 8 | bb = 33.976886930000695 9 | @printf("%.2f %.2f\n", aa, bb) #> 1.52 33.98 10 | # or to create another string: 11 | str = @sprintf("%0.3f", x) 12 | show(str) #> "7.357" 13 | println() 14 | # e = scientific format with e: 15 | @printf("%0.6e\n", x) #> 7.356790e+00 16 | # c = for characters: 17 | @printf("output: %c\n", 'α') #> output: α 18 | # s for strings: 19 | @printf("%s\n", "I like Julia") 20 | # right justify: 21 | @printf("%50s\n", "text right justified!") 22 | # p for pointers: 23 | @printf("a pointer: %p\n", 1e10) #> a pointer: 0x00000002540be400 -------------------------------------------------------------------------------- /Chapter02/regexp.jl: -------------------------------------------------------------------------------- 1 | email_pattern = r".+@.+" 2 | input = "john.doe@mit.edu" 3 | println(occursin(email_pattern, input)) #> true 4 | 5 | visa = r"^(?:4[0-9]{12}(?:[0-9]{3})?)$" 6 | input = "4457418557635128" 7 | 8 | occursin(visa, input) #> true 9 | if occursin(visa, input) 10 | println("credit card found") 11 | m = match(visa, input) 12 | println(m.match) #> 4457418557635128 13 | # println(m.captures) #> nothing 14 | println(m.offset) #> 1 15 | println(m.offsets) #> [] 16 | end 17 | 18 | email_pattern = r"(.+)@(.+)" 19 | input = "john.doe@mit.edu" 20 | m = match(email_pattern, input) 21 | println(m.captures) #> ["john.doe","mit.edu"] 22 | 23 | m = match(r"(ju|l)(i)?(a)", "Julia") 24 | println(m.match) #> "lia" 25 | println(m.captures) #> l - i - a 26 | println(m.offset) #> 3 27 | println(m.offsets) #> 3 - 4 - 5 28 | 29 | str = "The sky is blue" 30 | reg = r"[\w]{3,}" 31 | r = collect((m.match for m = eachmatch(reg, str))) 32 | show(r) #> ["The","sky","blue"] 33 | # eachmatch returns an iterator over all the matches 34 | iter = eachmatch(reg, str) 35 | for i in iter 36 | println("\"$(i.match)\" ") 37 | end -------------------------------------------------------------------------------- /Chapter02/scope.jl: -------------------------------------------------------------------------------- 1 | # type annotations and scope: 2 | x = 1.0 # x is Float64 3 | x = 1 # now x is Int 4 | # y::Float64 = 1.0 5 | # ERROR: syntax: type declarations on global variables are not yet supported 6 | 7 | function scopetest() 8 | println(x) 9 | y::Float64 = 1.0 # y must be Float64, this is not possible in global scope 10 | # y = 1 11 | end 12 | 13 | scopetest() 14 | #> 1 15 | #> 1.0 16 | # println(y) #> ERROR: UndefVarError: y not defined 17 | 18 | # compound expressions: 19 | x = begin 20 | a = 5 21 | 2 * a 22 | end # after: x is 10 23 | println(a) #> a is 5 24 | x = (a = 5; 2 * a) #> 10 -------------------------------------------------------------------------------- /Chapter02/strings_arrays.jl: -------------------------------------------------------------------------------- 1 | using Statistics 2 | # a newspaper headline: 3 | str = "The Gold and Blue Loses a Bit of Its Luster" 4 | println(str) 5 | nchars = length(str) 6 | println("The headline counts $nchars characters") # 43 7 | str2 = replace(str, "Blue" => "Red") 8 | 9 | # strings are immutable 10 | println(str) # The Gold and Blue Loses a Bit of Its Luster 11 | println(str2) 12 | println("Here are the characters at position 25 to 30:") 13 | subs = str[25:30] 14 | print("-$(lowercase(subs))-") # "-a bit -" 15 | println("Here are all the characters:") 16 | for c in str 17 | println(c) 18 | end 19 | arr = split(str,' ') 20 | show(arr) # ["The","Gold","and","Blue","Loses","a","Bit","of","Its","Luster"] 21 | nwords = length(arr) 22 | println("The headline counts $nwords words") # 10 23 | println("Here are all the words:") 24 | for word in arr 25 | println(word) 26 | end 27 | arr[4] = "Red" 28 | show(arr) # arrays are mutable 29 | println("Convert back to a sentence:") 30 | nstr = join(arr, ' ') 31 | println(nstr) # The Gold and Red Loses a Bit of Its Luster 32 | # working with arrays: 33 | using Statistics 34 | println("arrays: calculates the sum, mean and standard deviation ") 35 | arr = collect(1:100) 36 | typeof(arr) #> Array{Int64,1} 37 | println(sum(arr)) #> 5050 38 | println(mean(arr)) #> 50.5 -------------------------------------------------------------------------------- /Chapter03/anonymous.jl: -------------------------------------------------------------------------------- 1 | # anonymous functions: 2 | (x, y) -> x^3 - y + x * y 3 | f = (x, y) -> x^3 - y + x * y 4 | println(f(3, 2) ) # 31 5 | 6 | function (x) 7 | x + 2 8 | end 9 | 10 | (x) -> x + 2 11 | x -> x + 2 # lambda syntax 12 | () -> println("hello, Julia") 13 | (x, y, z) -> 3x + 2y - z -------------------------------------------------------------------------------- /Chapter03/arguments.jl: -------------------------------------------------------------------------------- 1 | # optional arguments: 2 | f(a, b = 5) = a + b 3 | f(1) #> 6 4 | f(2, 5) #> 7 5 | f(3) #> 8 6 | # f() #> ERROR: MethodError: no method matching f() 7 | # f(1, 2, 3) 8 | #> ERROR: MethodError: no method matching f(::Int64, ::Int64, ::Int64) 9 | # f(2, b = 5) #> ERROR: function f does not accept keyword arguments 10 | 11 | # keyword arguments: 12 | k(x; a1 = 1, a2 = 2) = x * (a1 + a2) 13 | k(3, a2 = 3) #> 12 14 | k(3, a2 = 3, a1 = 0) #> 9 15 | k(3) #> 9 16 | 17 | # combine all kinds of arguments in the same function 18 | function allargs(normal_arg, optional_positional_arg=2; keyword_arg="ABC") 19 | print("normal arg: $normal_arg -") 20 | print("optional arg: $optional_positional_arg -") 21 | print("keyword arg: $keyword_arg") 22 | end 23 | 24 | allargs(1, 3, keyword_arg=4) 25 | # prints: normal arg: 1 - optional arg: 3 - keyword arg: 4 26 | 27 | function varargs2(;args...) 28 | args 29 | end 30 | varargs2(k1="name1", k2="name2", k3=7) 31 | #> pairs(::NamedTuple) with 3 entries: 32 | # :k1 => "name1" 33 | # :k2 => "name2" 34 | # :k3 => 7 -------------------------------------------------------------------------------- /Chapter03/first_class.jl: -------------------------------------------------------------------------------- 1 | mult(x, y) = x * y 2 | typeof(mult) #> Function 3 | m = mult 4 | m(6, 6) #> 36 5 | 6 | plustwo = function (x) 7 | x + 2 8 | end 9 | plustwo(3) #> 5 10 | 11 | 3+4 #> 7 12 | +(3,4) #> 7 13 | 14 | function numerical_derivative(f, x, dx=0.01) 15 | derivative = (f(x+dx) - f(x-dx))/(2*dx) 16 | return derivative 17 | end 18 | 19 | f = x -> 2x^2 + 30x + 9 20 | println(numerical_derivative(f, 1, 0.001)) #> 33.99999999999537 21 | 22 | function derivative(f) 23 | return function(x) 24 | # pick a small value for h 25 | h = x == 0 ? sqrt(eps(Float64)) : sqrt(eps(Float64)) * x 26 | xph = x + h 27 | dx = xph - x 28 | f1 = f(xph) # evaluate f at x + h 29 | f0 = f(x) # evaluate f at x 30 | return (f1 - f0) / dx # divide by h 31 | end 32 | end 33 | 34 | # closure: 35 | function counter() 36 | n = 0 37 | () -> n += 1, () -> n = 0 38 | end 39 | 40 | (addOne, reset) = counter() 41 | addOne() 42 | addOne() 43 | addOne() 44 | reset() 45 | 46 | # currying: 47 | function add(x) 48 | return function f(y) 49 | return x + y 50 | end 51 | end 52 | add(1)(2) #> 3 53 | add(x) = f(y) = x + y 54 | add(x) = y -> x + y 55 | 56 | # nested: 57 | function afun(x) 58 | z = x * 2 59 | function b(z) 60 | z += 1 61 | end 62 | b(z) 63 | end 64 | 65 | d = 5 66 | afun(d) #> 11 67 | 68 | # recursive: 69 | sum(n) = n > 1 ? sum(n-1) + n : n 70 | sum(100) #> 5050 71 | fib(n) = n < 2 ? n : fib(n-1) + fib(n-2) 72 | println(fib(25)) #> 75025 -------------------------------------------------------------------------------- /Chapter03/functions101.jl: -------------------------------------------------------------------------------- 1 | # n = mult(3, 4) #> ErrorException("mult not defined")) 2 | function mult(x, y) 3 | println("x is $x and y is $y") 4 | x * y 5 | end 6 | 7 | n = mult(3, 4) #> 12 8 | 9 | function mult(x, y) 10 | println("x is $x and y is $y") 11 | if x == 1 12 | return y 13 | end 14 | x * y 15 | end 16 | 17 | function multi(n, m) 18 | n * m, div(n, m), n % m 19 | end 20 | x, y, z = multi(8, 2) #> (16,4,0) 21 | 22 | # variable number of arguments: 23 | function varargs(n, m, args...) 24 | println("arguments: $n $m $args") 25 | end 26 | varargs(1, 2, 3, 4) #> arguments: 1 2 (3, 4) 27 | 28 | function varargs2(args...) 29 | println("arguments2: $args") 30 | end 31 | 32 | x = (3, 4) 33 | varargs2(1, 2, x...) # args is (1,2,3,4) 34 | x = [10, 11, 12] 35 | varargs2(1, 2, x...) # args is (1,2,10,11,12) 36 | 37 | function insert_elem(arr) 38 | push!(arr, -10) 39 | end 40 | 41 | arr = [ 2, 3, 4] 42 | insert_elem(arr) 43 | println("arr is now $arr") #> arr is now [ 2, 3, 4, -10 ] 44 | 45 | # typing the arguments: 46 | function mult(x::Float64, y::Float64) 47 | println("x is $x and y is $y") 48 | x * y 49 | end 50 | # following gives error: 51 | # mult(5, 6) 52 | # ERROR: `mult` has no method matching mult(::Int64, ::Int64) 53 | 54 | # one-line assignment syntax: 55 | mult(x, y) = x * y 56 | f(x, y) = x^3 - y + x*y 57 | println(f(3,2) ) # 31 58 | 59 | ∑(x,y) = x + y 60 | ∑(3, 4) #> 7 -------------------------------------------------------------------------------- /Chapter03/generic_functions.jl: -------------------------------------------------------------------------------- 1 | # multiple dispatch: 2 | f(n, m) = "base case" 3 | f(n::Number, m::Number) = "n and m are both numbers" 4 | f(n::Number, m) = "n is a number" 5 | f(n, m::Number) = "m is a number" 6 | f(n::Integer, m::Integer) = "n and m are both integers" 7 | #> f (generic function with 5 methods) 8 | f(1.5, 2) #> "n and m are both numbers" 9 | f(1, "bar") #> "n is a number" 10 | f(1, 2) #> "n and m are both integers" 11 | f("foo", [1,2]) #> "base case" 12 | f(n::Float64, m::Integer) = "n is a float and m is an integer" 13 | #> f (generic function with 6 methods) 14 | f(1.5, 2) #> "n is a float and m is an integer" 15 | 16 | # methods: 17 | methods(+) 18 | methods(sort) 19 | 20 | using InteractiveUtils 21 | InteractiveUtils.methodswith(String) 22 | 23 | # measuring execution: 24 | fib(n) = n < 2 ? n : fib(n-1) + fib(n-2) 25 | @time fib(35) 26 | @elapsed fib(35) #> elapsed time: 0.115853481 seconds (45144 bytes allocated) 27 | 28 | # broadcasting: 29 | arr = [1.0, 2.0, 3.0] 30 | sin.(arr) 31 | #> 3-element Array{Float64,1}: 32 | # 0.8414709848078965 33 | # 0.9092974268256817 34 | # 0.1411200080598672 35 | 36 | f(x,y) = x + 7y 37 | f.(pi, arr) 38 | #> 3-element Array{Float64,1}: 39 | # 10.141592653589793 40 | # 17.141592653589793 41 | # 24.141592653589793 -------------------------------------------------------------------------------- /Chapter03/map_filters.jl: -------------------------------------------------------------------------------- 1 | # maps: 2 | map(x -> x * 10, [1, 2, 3]) #> [10, 20, 30] 3 | cubes = map(x-> Base.power_by_squaring(x, 3), collect(1:5)) #> [1, 8, 27, 64, 125] 4 | map(*, [1, 2, 3], [4, 5, 6]) #> [4, 10, 18] 5 | 6 | # do block: 7 | map( x -> begin 8 | if x == 0 return 0 9 | elseif iseven(x) return 2 10 | elseif isodd(x) return 1 11 | end 12 | end, 13 | collect(-3:3)) #> [1,2,1,0,1,2,1] 14 | 15 | map(collect(-3:3)) do x 16 | if x == 0 return 0 17 | elseif iseven(x) return 2 18 | elseif isodd(x) return 1 19 | end 20 | end #> [1,2,1,0,1,2,1] 21 | 22 | # filter: 23 | filter( n -> iseven(n), collect(1:10) )#> [2, 4, 6, 8, 10] 24 | filter( n -> n % 2 == 0, collect(1:10) )#> [2, 4, 6, 8, 10] 25 | 26 | # comprehensions: 27 | arr0 = [n for n in 1:1000] #> [1,2,...,1000] 28 | # better write it as arr0 = [1:1000] 29 | arr = Float64[x^2 for x in 1:4] #> [1.0,4.0,9.0,16.0] 30 | cubes = [x^3 for x in collect(1:5)] #> [1, 8, 27, 64, 125] 31 | mat1 = [x + y for x in 1:2, y in 1:3] #> creates a 2 x 3 Array{Int64,2}: 32 | # 2 3 4 33 | # 3 4 5 34 | table10 = [x*y for x=1:10, y=1:10] #> 35 | #= 36 | #1 2 3 4 5 6 7 8 9 10 37 | #2 4 6 8 10 12 14 16 18 20 38 | #3 6 9 12 15 18 21 24 27 30 39 | #4 8 12 16 20 24 28 32 36 40 40 | #5 10 15 20 25 30 35 40 45 50 41 | #6 12 18 24 30 36 42 48 54 60 42 | #7 14 21 28 35 42 49 56 63 70 43 | #8 16 24 32 40 48 56 64 72 80 44 | #9 18 27 36 45 54 63 72 81 90 45 | #10 20 30 40 50 60 70 80 90 100 46 | =# 47 | 48 | arrany = Any[i * 2 for i in 1:5] #> [2,4,6,8,10] 49 | [ sqrt(exp(i))-j for i = 1:8, j = 1:8] 50 | # 8x8 Array{Float64,2}: 51 | # 0.648721 -0.351279 -1.35128 … -4.35128 -5.35128 -6.35128 52 | # 1.71828 0.718282 -0.281718 -3.28172 -4.28172 -5.28172 53 | # 3.48169 2.48169 1.48169 -1.51831 -2.51831 -3.51831 54 | # 6.38906 5.38906 4.38906 1.38906 0.389056 -0.610944 55 | # 11.1825 10.1825 9.18249 6.18249 5.18249 4.18249 56 | # 19.0855 18.0855 17.0855 … 14.0855 13.0855 12.0855 57 | # 32.1155 31.1155 30.1155 27.1155 26.1155 25.1155 58 | # 53.5982 52.5982 51.5982 48.5982 47.5982 46.5982 -------------------------------------------------------------------------------- /Chapter04/conditional.jl: -------------------------------------------------------------------------------- 1 | var = 7 2 | if var > 10 3 | println("var has value $var and is bigger than 10.") 4 | elseif var < 10 # This elseif clause is optional. 5 | println("var has value $var and is smaller than 10.") 6 | else # The else clause is optional too. 7 | println("var has value $var and is 10.") 8 | end 9 | #> prints "var has value 7 and is smaller than 10." 10 | 11 | # if 0 print("ok") end 12 | # ERROR: LoadError: TypeError: non-boolean (Int64) used in boolean context 13 | a = 10 14 | b = 15 15 | z = if a > b a 16 | else b 17 | end 18 | println(z) #> 15 19 | z = a > b ? a : b # with ternary operator 20 | 21 | var = 7 22 | varout = "var has value $var" 23 | cond = var > 10 ? "and is bigger than 10." : var < 10 ? "and is smaller than 10" : "and is 10." 24 | println("$varout $cond") # var has value 7 and is smaller than 10 25 | 26 | function sqroot(n::Int) 27 | n >= 0 || error("n must be non-negative") 28 | n == 0 && return 0 29 | sqrt(n) 30 | end 31 | sqroot(4) #> 2.0 32 | sqroot(0) #> 0.0 33 | # sqroot(-6) #> ERROR: LoadError: n must be non-negative -------------------------------------------------------------------------------- /Chapter04/errors.jl: -------------------------------------------------------------------------------- 1 | arr = [1,2,3] 2 | # arr[0] #> causes a program stop with: ERROR: BoundsError() 3 | # sqrt(-3) #> causes an ERROR: DomainError: sqrt with -3.0: 4 | # sqrt will only return a complex result if called with a complex argument. 5 | sqrt(complex(-3)) #> 0.0 + 1.7320508075688772im 6 | 7 | mutable struct CustomException <: Exception 8 | end 9 | 10 | # throw: 11 | codes = ["AO", "ZD", "SG", "EZ"] 12 | # code = "AR" 13 | code = "AO" 14 | if code in codes # in(code, codes) 15 | println("This is an acceptable code") 16 | else 17 | throw(DomainError()) 18 | end 19 | 20 | # error: 21 | function sqroot(n::Int) 22 | n >= 0 || error("n must be non-negative") 23 | n == 0 && return 0 24 | sqrt(n) 25 | end 26 | sqroot(4) #> 2.0 27 | sqroot(0) #> 0.0 28 | # sqroot(-6) #> ERROR: n must be non-negative 29 | 30 | # try / catch 31 | a = [] 32 | try 33 | pop!(a) 34 | catch ex 35 | println(typeof(ex)) #> ArgumentError 36 | backtrace() 37 | showerror(stdout, ex) #> ArgumentError: array must be non-empty 38 | end 39 | 40 | try 41 | # try this code 42 | catch ex 43 | if isa(ex, DomainError) 44 | # do this 45 | elseif isa(ex, BoundsError) 46 | # do this 47 | end 48 | end 49 | 50 | ret = try 51 | global a = 4 * 2 52 | catch ex 53 | end 54 | println(ret) #> 8 55 | 56 | # finally 57 | try 58 | global f = open("file1.txt", "r") #> IOStream() 59 | # operate on file f, for example: 60 | # alternative: open("file1.txt", "r") do f 61 | k = 0 62 | while(!eof(f)) 63 | a=readline(f) 64 | println(a) 65 | k += 1 66 | end 67 | println("\nNumber of lines in file: $k") 68 | catch ex 69 | finally 70 | close(f) 71 | end 72 | 73 | 74 | -------------------------------------------------------------------------------- /Chapter04/file1.txt: -------------------------------------------------------------------------------- 1 | Twas brillig and the slithy toves 2 | Did gyre and gimble in the wabe 3 | All mimsy were the borogroves 4 | And the momeraths outgrabe 5 | -------------------------------------------------------------------------------- /Chapter04/repetitions.jl: -------------------------------------------------------------------------------- 1 | coll = [1:50] 2 | for e in coll 3 | # process(e) executed for every element e in coll 4 | end 5 | 6 | for n = 1:10 println(n^3) end 7 | for n = 1:10 8 | println(n^3) 9 | end 10 | # prints: 11 | #1 12 | #8 13 | #27 14 | #64 15 | #125 16 | #216 17 | #343 18 | #512 19 | #729 20 | #1000 21 | 22 | # iterate over index: 23 | arr = [x^2 for x in 1:10] 24 | #10-element Array{Int64,1}: 25 | # 1 26 | # 4 27 | # 9 28 | # 16 29 | # 25 30 | # 36 31 | # 49 32 | # 64 33 | # 81 34 | # 100 35 | 36 | for i = 1:length(arr) 37 | println("the $i-th element is $(arr[i])") 38 | end 39 | # the 1-th element is 1 40 | # the 2-th element is 4 41 | # the 3-th element is 9 42 | # the 4-th element is 16 43 | # the 5-th element is 25 44 | # the 6-th element is 36 45 | # the 7-th element is 49 46 | # the 8-th element is 64 47 | # the 9-th element is 81 48 | # the 10-th element is 100 49 | 50 | for (ix, val) in enumerate(arr) 51 | println("the $ix-th element is $val") 52 | end 53 | # 1 1 54 | # 2 4 55 | # 3 9 56 | # 4 16 57 | # 5 25 58 | # 6 36 59 | # 7 49 60 | # 8 64 61 | # 9 81 62 | # 10 100 63 | 64 | for n = 1:5 65 | for m = 1:5 66 | println("$n * $m = $(n * m)") 67 | end 68 | end 69 | 70 | for n = 1:5, m = 1:5 71 | println("$n * $m = $(n * m)") 72 | end 73 | # 74 | #1 * 1 = 1 75 | #1 * 2 = 2 76 | #1 * 3 = 3 77 | #1 * 4 = 4 78 | #1 * 5 = 5 79 | #2 * 1 = 2 80 | #2 * 2 = 4 81 | #2 * 3 = 6 82 | #2 * 4 = 8 83 | #2 * 5 = 10 84 | #3 * 1 = 3 85 | #3 * 2 = 6 86 | #3 * 3 = 9 87 | #3 * 4 = 12 88 | #3 * 5 = 15 89 | #4 * 1 = 4 90 | #4 * 2 = 8 91 | #4 * 3 = 12 92 | #4 * 4 = 16 93 | #4 * 5 = 20 94 | #5 * 1 = 5 95 | #5 * 2 = 10 96 | #5 * 3 = 15 97 | #5 * 4 = 20 98 | #5 * 5 = 25 99 | 100 | # while loop: 101 | a = 10 102 | b = 15 103 | while a < b 104 | # process(a) 105 | println(a) 106 | global a += 1 107 | end 108 | # prints: 109 | #10 110 | #11 111 | #12 112 | #13 113 | #14 114 | 115 | # loop over array that is changing in the loop: 116 | arr = [1,2,3,4] 117 | while !isempty(arr) 118 | print(pop!(arr), ", ") 119 | end 120 | # => 4, 3, 2, 1, 121 | # julia> arr 122 | # 0-element Array{Int64,1} 123 | 124 | # break: 125 | a = 10 126 | b = 150 127 | while a < b 128 | # process(a) 129 | println(a) 130 | global a += 1 131 | if a >= 50 132 | break 133 | end 134 | end 135 | 136 | arr = rand(1:10, 10) 137 | println(arr) 138 | # get the index of search in an array arr: 139 | searched = 4 140 | for (ix, curr) in enumerate(arr) 141 | if curr == searched 142 | println("The searched element $searched occurs on index $ix") 143 | break 144 | end 145 | end 146 | #= 147 | [8,4,3,6,3,5,4,4,6,6] 148 | The searched element 4 occurs on index 2 149 | =# 150 | 151 | # continue: 152 | for n in 1:10 153 | if 3 <= n <= 6 154 | continue # skip one iteration 155 | end 156 | println(n) 157 | end -------------------------------------------------------------------------------- /Chapter04/scope.jl: -------------------------------------------------------------------------------- 1 | # variant 1: 2 | x = 9 3 | function funscope(n) 4 | x = 0 # x is in the local scope of the function 5 | for i = 1:n 6 | local x # x is local to the for loop 7 | x = i + 1 8 | if (x == 7) 9 | println("This is the local x in for: $x") #> 7 10 | end 11 | end 12 | println("This is the local x in funscope: $x") #> 0 13 | global x = 15 14 | end 15 | funscope(10) 16 | println("This is the global x: $x") #> 15 17 | #= 18 | This is the local x in for: 7 19 | This is the local x in funscope: 0 20 | This is the global x: 15 21 | =# 22 | 23 | # variant 2: 24 | x = 9 25 | function funscope(n) 26 | x = 0 27 | for i = 1:n 28 | x = i + 1 29 | if (x == 7) 30 | println("This is the local x in funscope: $x") #> 7 31 | end 32 | end 33 | println("This is the local x in funscope: $x") #> 11 34 | global x = 15 35 | end 36 | funscope(10) 37 | println("This is the global x: $x") #> 15 38 | #= 39 | This is the local x in funscope: 7 40 | This is the local x in funscope: 11 41 | This is the global x: 15 42 | =# 43 | 44 | # variant 3: 45 | x = 9 46 | function funscope(n) 47 | x = 0 48 | for i = 1:n 49 | x = i + 1 50 | if (x == 7) 51 | println("This is the local x in for: $x") #> 7 52 | end 53 | end 54 | println("This is the local x in funscope: $x") #> 11 55 | end 56 | funscope(10) 57 | println("This is the global x: $x") #> 9 58 | #= 59 | This is the local x in for: 7 60 | This is the local x in funscope: 11 61 | This is the global x: 9 62 | =# 63 | 64 | # without let: 65 | anon = Array{Any}(undef, 2) 66 | for i = 1:2 67 | anon[i] = ()-> println(i) 68 | i += 1 69 | end 70 | anon[1]() #> 2 71 | anon[2]() #> 3 72 | 73 | # with let: 74 | anon = Array{Any}(undef, 2) 75 | for i = 1:2 76 | let i = i 77 | anon[i] = ()-> println(i) 78 | end 79 | i += 1 80 | end 81 | anon[1]() #> 1 82 | anon[2]() #> 2 83 | 84 | # combined with begin: 85 | begin 86 | local x = 1 87 | let 88 | local x = 2 89 | println(x) #> 2 90 | end 91 | x 92 | println(x) #> 1 93 | end 94 | 95 | # for-loops and comprehensions: 96 | i = 0 97 | for i = 1:10 98 | end 99 | println(i) #> 10 100 | 101 | i = 0 102 | [i for i = 1:10 ] 103 | println(i) #> 0 -------------------------------------------------------------------------------- /Chapter04/tasks.jl: -------------------------------------------------------------------------------- 1 | function fib_producer(c::Channel) 2 | a, b = (0, 1) 3 | for i = 1:10 4 | put!(c, b) 5 | a, b = (b, a + b) 6 | end 7 | end 8 | 9 | chnl = Channel(fib_producer) #> Channel{Any}(sz_max:0,sz_curr:1) 10 | 11 | take!(chnl) #> 1 12 | take!(chnl) #> 1 13 | take!(chnl) #> 2 14 | take!(chnl) #> 3 15 | take!(chnl) #> 5 16 | take!(chnl) #> 8 17 | take!(chnl) #> 13 18 | take!(chnl) #> 21 19 | take!(chnl) #> 34 20 | take!(chnl) #> 55 21 | # take!(chnl) #> ERROR: InvalidStateException("Channel is closed.", :closed) 22 | 23 | for n in chnl 24 | println(n) 25 | end 26 | #> 1 1 1 2 3 5 8 13 21 34 55 27 | 28 | chnl = @task fib_producer(c::Channel) # Task (runnable) @0x0000000005696d80 29 | 30 | fac(i::Integer) = (i > 1) ? i*fac(i - 1) : 1 31 | c = Channel(0) 32 | task = @async foreach(i->put!(c,fac(i)), 1:5) 33 | bind(c,task) 34 | for i in c 35 | @show i 36 | end 37 | # i = 1 38 | # i = 2 39 | # i = 6 40 | # i = 24 41 | # i = 120 -------------------------------------------------------------------------------- /Chapter05/dicts.jl: -------------------------------------------------------------------------------- 1 | d1 = Dict(1 => 4.2, 2 => 5.3) 2 | # Dict{Int64,Float64} with 2 entries: 3 | # 2 => 5.3 4 | # 1 => 4.2 5 | d1 = Dict{Int64,Float64}(1 => 4.2, 2 => 5.3) 6 | d1 = [1 => 4.2, 2 => 5.3] 7 | # 2-element Array{Pair{Int64,Float64},1}: 8 | # 1 => 4.2 9 | # 2 => 5.3 10 | 11 | d2 = Dict{Any,Any}("a"=>1, (2,3)=>true) 12 | 13 | d3 = Dict(:A => 100, :B => 200) 14 | # Dict{Symbol,Int64} with 2 entries: 15 | # :A => 100 16 | # :B => 200 17 | d3 = Dict{Symbol,Int64}(:A => 100, :B => 200) 18 | d3[:B] #> 200 19 | # d3[:Z] #> ERROR: KeyError: key :Z not found 20 | get(d3, :Z, 999) #> 999 21 | 22 | d3[:A] = 150 #> d3 is now [:A => 150, :B => 200] 23 | d3[:C] = 300 #> d3 is now [:A => 150, :B => 200, :C => 300] 24 | length(d3) #> 3 25 | # d3["CVO"] = 500 #> ERROR: KeyError: key "CVO" not found 26 | # d3[:CVO] = "Julia" #> ERROR: KeyError: key "CVO" not found 27 | 28 | dmus = Dict{Symbol,String}(:first_name => "Louis", :surname => "Armstrong", :occupation => "musician", 29 | :date_of_birth => "4/8/1901") 30 | # Dict{Symbol,String} with 4 entries: 31 | # :date_of_birth => "4/8/1901" 32 | # :occupation => "musician" 33 | # :surname => "Armstrong" 34 | # :first_name => "Louis" 35 | 36 | haskey(d3, :Z) #> false 37 | haskey(d3, :B) #> true 38 | 39 | d4 = Dict() #> Dict{Any,Any} with 0 entries 40 | d4["lang"] = "Julia" 41 | 42 | d5 = Dict{Float64, Int64}() #> Dict{Float64,Int64} with 0 entries 43 | # d5["c"] = 6 #> ERROR: MethodError: `convert` has no method matching convert(::Type{Float64}, ::ASCIIString) 44 | 45 | d3 = Dict(:A => 100, :B => 200) 46 | delete!(d3, :B) #> Dict{Symbol,Int64} with 1 entry: :A => 100 47 | 48 | d3 = Dict(:A => 100, :B => 200) 49 | ki = keys(d3) #> KeyIterator 50 | for k in ki 51 | println(k) 52 | end #> A B 53 | :A in ki #> true 54 | :Z in ki #> false 55 | 56 | collect(keys(d3)) #> 2-element Array{Symbol,1}: 57 | # :A 58 | # :B 59 | vi = values(d3) #> ValueIterator 60 | for v in values(d3) 61 | println(v) 62 | end #> 100 200 63 | 64 | keys1 = ["J.S. Bach", "Woody Allen", "Barack Obama"] 65 | values1 = [ 1685, 1935, 1961] 66 | d5 = Dict(zip(keys1, values1)) 67 | #> 68 | # Dict{String,Int64} with 3 entries: 69 | # "J.S. Bach" => 1685 70 | # "Woody Allen" => 1935 71 | # "Barack Obama" => 1961 72 | 73 | for (k, v) in d5 74 | println("$k was born in $v") 75 | end 76 | for p in d5 77 | println("$(p[1]) was born in $(p[2])") 78 | end 79 | #J.S. Bach was born in 1685 80 | #Barack Obama was born in 1961 81 | #Woody Allen was born in 1935 82 | 83 | capitals = Dict{String, String}("France"=> "Paris", "China"=>"Beijing") 84 | # Dict{String,String} with 2 entries: 85 | # "China" => "Beijing" 86 | # "France" => "Paris" 87 | 88 | # neat tricks: 89 | dict = Dict("a" => 1, "b" => 2, "c" => 3) 90 | arrkey = [key for (key, value) in dict] #> 3-element Array{String,1}: "a" "b" "c" 91 | # same as collect(keys(dict)) 92 | arrval = [value for (key, value) in dict] #> 3-element Array{Int64,1}: 1 2 3 93 | # same as collect(values(dict)) 94 | -------------------------------------------------------------------------------- /Chapter05/matrices.jl: -------------------------------------------------------------------------------- 1 | [1, 2, 3] 2 | [1 2 3] 3 | [1; 2; 3] 4 | # 3-element Array{Int64,1}: 5 | # 1 6 | # 2 7 | # 3 8 | 9 | Array{Int64, 1} == Vector{Int64} #> true 10 | Array{Int64, 2} == Matrix{Int64} #> true 11 | 12 | [1 2] * [3 ; 4] #> 11 13 | [1 2] .* [3 ; 4] 14 | # 2 Array{Int64,2}: 15 | # 3 6 16 | # 4 8 17 | 18 | matrix1 = [1 2; 3 4] 19 | matrix1[2, 1] #> 3 20 | matrix2 = [5 6; 7 8] 21 | println(matrix1 * matrix2) 22 | #= 23 | [19 22 24 | 43 50] 25 | =# 26 | 27 | ma1 = rand(3, 5) 28 | ndims(ma1) #> 2 29 | size(ma1) #> (3, 5) 30 | nrows, ncols = size(ma1) 31 | size(ma1,1) #> 3 32 | size(ma1,2) #> 5 33 | length(ma1) #> 15 34 | 35 | using LinearAlgebra 36 | idm = Matrix(1.0*I, 3, 3) 37 | idm[1:end, 2] #> 2nd column 38 | idm[2, :] #> 2nd row 39 | idmc = idm[2:end, 2:end] 40 | #2x2 Array{Float64,2}: 41 | # 1.0 0.0 42 | # 0.0 1.0 43 | idm[2, :] .= 0 44 | # idm 45 | # 3x3 Array{Float64,2}: 46 | # 1.0 0.0 0.0 47 | # 0.0 0.0 0.0 48 | # 0.0 0.0 1.0 49 | idm[2:end, 2:end] = [ 5 7 ; 9 11] 50 | # idm 51 | # 3x3 Array{Float64,2}: 52 | # 1.0 0.0 0.0 53 | # 0.0 5.0 7.0 54 | # 0.0 9.0 11.0 55 | 56 | a = [1 2;3 4] 57 | # 2 Array{Int64,2}: 58 | # 1 2 59 | # 3 4 60 | 61 | a[:] 62 | # 4-element Array{Int64,1}: 63 | # 1 64 | # 3 65 | # 2 66 | # 4 67 | 68 | jarr = (Array{Int64, 1})[] 69 | push!(jarr, [1,2]) 70 | push!(jarr, [1,2,3,4]) 71 | push!(jarr, [1,2,3]) 72 | jarr #> 73 | #3-element Array{Array{Int64,1},1}: 74 | # [1,2] 75 | # [1,2,3,4] 76 | # [1,2,3] 77 | 78 | ma = [1 2; 3 4] 79 | ma[:] 80 | # 4-element Array{Int64,1}: 81 | # 1 82 | # 3 83 | # 2 84 | # 4 85 | ma' #> [1 3; 2 4] 86 | ma * ma' #> 87 | #5 11 88 | #11 25 89 | ma .* ma' #> 2x2 Array{Int64,2}: 90 | #1 6 91 | #6 16 92 | 93 | inv(ma) #> 2x2 Array{Float64,2}: 94 | # -2.0 1.0 95 | # 1.5 -0.5 96 | 97 | ma * inv(ma) #> 2x2 Array{Float64,2}: 98 | # 1.0 0.0 99 | # 8.88178e-16 1.0 100 | 101 | v = [1.,2.,3.] #> equivalent to v = [1.0,2.0,3.0] 102 | w = [2.,4.,6.] 103 | append!(v, w) 104 | #6-element Array{Float64,1}: 105 | # 1.0 106 | # 2.0 107 | # 3.0 108 | # 2.0 109 | # 4.0 110 | # 6.0 111 | v = [1.,2.,3.] 112 | hcat(v,w) 113 | # 3x2 Array{Float64,2}: 114 | # 1.0 2.0 115 | # 2.0 4.0 116 | # 3.0 6.0 117 | vcat(v,w) 118 | # 6-element Array{Float64,1}: 119 | # 1.0 120 | # 2.0 121 | # 3.0 122 | # 2.0 123 | # 4.0 124 | # 6.0 125 | 126 | a = [1 2; 3 4] 127 | # 2x2 Array{Int64,2}: 128 | # 1 2 129 | # 3 4 130 | 131 | b = [5 6; 7 8] 132 | # 2x2 Array{Int64,2}: 133 | # 5 6 134 | # 7 8 135 | 136 | c = [a b] 137 | # 2x4 Array{Int64,2}: 138 | # 1 2 5 6 139 | # 3 4 7 8 140 | 141 | c = [a; b] 142 | # 4x2 Array{Int64,2}: 143 | # 1 2 144 | # 3 4 145 | # 5 6 146 | # 7 8 147 | 148 | c = [a, b] 149 | # 4x2 Array{Int64,2}: 150 | # 1 2 151 | # 3 4 152 | # 5 6 153 | # 7 8 154 | 155 | reshape(1:12, 3, 4) 156 | # 3x4 Array{Int64,2}: 157 | # 1 4 7 10 158 | # 2 5 8 11 159 | # 3 6 9 12 160 | 161 | a = rand(3, 3) 162 | # 3x3 Array{Float64,2}: 163 | # 0.332401 0.499608 0. 164 | # 0.0933291 0.132798 0. 165 | # 0.722452 0.932347 0. 166 | 167 | reshape(a, (9,1)) 168 | # 9x1 Array{Float64,2}: 169 | # 0.332401 170 | # 0.0933291 171 | # 0.722452 172 | # 0.499608 173 | # 0.132798 174 | # 0.932347 175 | # 0.355623 176 | # 0.967591 177 | # 0.809577 178 | 179 | # reshape(a, (2,2)) 180 | # ERROR: DimensionMismatch("new dimensions (2,2) must be consistent with array size 9") 181 | 182 | # copy and deepcopy: 183 | x = Array{Any}(undef, 2) #> 2-element Array{Any,1}: #undef #undef 184 | x[1] = ones(2) #> 2-element Array{Float64} 1.0 1.0 185 | x[2] = trues(3) #> 3-element BitArray{1}: true true true 186 | x #> 2-element Array{Any,1}: [1.0,1.0] Bool[true,true,true] 187 | a = x #> 2-element Array{Any,1}: [1.0,1.0] Bool[true,true,true] 188 | b = copy(x) #> 2-element Array{Any,1}: [1.0,1.0] Bool[true,true,true] 189 | c = deepcopy(x) #> 2-element Array{Any,1}: [1.0,1.0] Bool[true,true,true] 190 | x[1] = "Julia" 191 | x[2][1] = false 192 | x #> 2-element Array{Any,1}: "Julia" Bool[false,true,true] 193 | a #> 2-element Array{Any,1}: "Julia" Bool[false,true,true] 194 | isequal(a, x) #> true, a is identical to x 195 | b #> 2-element Array{Any,1}: [1.0,1.0] Bool[false,true,true] 196 | isequal(b, x) #> false, b is a shallow copy of x 197 | c #> 2-element Array{Any,1}: [1.0,1.0] Bool[true,true,true] 198 | isequal(c, x) #> false -------------------------------------------------------------------------------- /Chapter05/results_words1.txt: -------------------------------------------------------------------------------- 1 | Word: frequency 2 | 3 | be: 2 4 | is: 1 5 | not: 1 6 | or: 1 7 | question: 1 8 | that: 1 9 | the: 1 10 | to: 2 -------------------------------------------------------------------------------- /Chapter05/results_words2.txt: -------------------------------------------------------------------------------- 1 | Word : frequency 2 | 3 | A : 6 4 | Ages : 1 5 | All : 1 6 | Alphonsus : 1 7 | Although : 2 8 | An : 1 9 | Arraying : 2 10 | As : 3 11 | Astronomy : 1 12 | At : 1 13 | August : 1 14 | Australia : 3 15 | BINARY : 1 16 | BRIEF : 1 17 | BY : 1 18 | Baseline : 1 19 | Bay : 1 20 | Because : 4 21 | Beginning : 1 22 | Being : 1 23 | Bigger : 1 24 | Binary : 2 25 | Bit : 1 26 | Both : 1 27 | Brightness : 1 28 | But : 1 29 | By : 2 30 | Byte : 1 31 | California : 2 32 | Canberra : 2 33 | Central : 1 34 | Clouds : 2 35 | Color : 1 36 | Configured : 1 37 | Crater : 2 38 | DSN : 8 39 | Data : 4 40 | Deep : 1 41 | During : 1 42 | Earth : 19 43 | Europa : 1 44 | European : 1 45 | Even : 1 46 | FACTS : 1 47 | FROM : 2 48 | Filters : 1 49 | First : 1 50 | For : 7 51 | From : 1 52 | GET : 2 53 | Galileo : 2 54 | Ganymede : 1 55 | Goldstone : 1 56 | Great : 1 57 | HISTORY : 1 58 | HOW : 2 59 | Haynes : 1 60 | His : 1 61 | However : 1 62 | If : 2 63 | Images : 3 64 | In : 5 65 | Instead : 1 66 | Interferometry : 1 67 | Io : 4 68 | JPL : 2 69 | Jet : 3 70 | Jovian : 1 71 | July : 1 72 | Jupiter : 13 73 | Laboratory : 3 74 | Long : 1 75 | Lunar : 5 76 | MISSION : 26 77 | Madrid : 1 78 | Mariner : 3 79 | Mariners : 1 80 | Mars : 7 81 | Mercury : 3 82 | Middle : 1 83 | Moon : 14 84 | NAME : 26 85 | NASA : 3 86 | NF : 1 87 | Neptune : 4 88 | Network : 1 89 | New : 1 90 | November : 1 91 | OF : 1 92 | Observatory : 1 93 | Ocean : 1 94 | Of : 1 95 | On : 3 96 | Once : 1 97 | Only : 1 98 | Orbiter : 5 99 | PICTURES : 3 100 | Parkes : 1 101 | Pasadena : 1 102 | Pioneer : 7 103 | Pluto : 2 104 | Propulsion : 3 105 | Radio : 1 106 | Ranger : 3 107 | Raster : 1 108 | Red : 1 109 | Reflected : 1 110 | Rhea : 1 111 | SPACE : 2 112 | SPACECRAFT : 1 113 | Saturn : 13 114 | Saturnian : 1 115 | Sea : 4 116 | September : 1 117 | Sequence : 2 118 | Since : 1 119 | Slowing : 1 120 | Solar : 4 121 | Space : 1 122 | Spacecraft : 1 123 | Spain : 1 124 | Spot : 1 125 | Stations : 1 126 | Storms : 1 127 | Surveyor : 6 128 | System : 4 129 | TABLE : 1 130 | TV : 1 131 | That : 4 132 | The : 30 133 | These : 2 134 | This : 3 135 | Those : 1 136 | Thus : 4 137 | To : 5 138 | Tranquility : 2 139 | Triton : 1 140 | Tycho : 1 141 | UNMANNED : 1 142 | Uranus : 10 143 | VLBI : 2 144 | Value : 4 145 | Values : 2 146 | Venus : 7 147 | Very : 1 148 | Viking : 2 149 | Voyager : 19 150 | WE : 2 151 | We : 1 152 | Whatever : 1 153 | When : 3 154 | While : 2 155 | YEAR : 26 156 | _____________________________________________________________________ : 1 157 | ______________________________________________________________________ : 1 158 | a : 76 159 | able : 1 160 | about : 5 161 | above : 2 162 | accompanied : 1 163 | accomplish : 1 164 | accomplished : 1 165 | accomplishment : 1 166 | accuracy : 2 167 | accurate : 2 168 | accurately : 1 169 | achieved : 1 170 | acquisition : 1 171 | across : 2 172 | action : 1 173 | active : 2 174 | add : 1 175 | adding : 2 176 | adjusting : 1 177 | after : 2 178 | aided : 1 179 | aim : 1 180 | aiming : 1 181 | all : 4 182 | allow : 2 183 | alone : 1 184 | alpha : 2 185 | alphabet : 1 186 | already : 1 187 | also : 2 188 | amber : 1 189 | amount : 3 190 | an : 14 191 | analyzed : 1 192 | ancient : 1 193 | and : 82 194 | angle : 1 195 | another : 2 196 | answered : 1 197 | antenna : 4 198 | antennas : 11 199 | anticipated : 1 200 | any : 2 201 | apart : 3 202 | apparent : 1 203 | appear : 4 204 | appears : 1 205 | approach : 1 206 | approaches : 1 207 | appropriate : 1 208 | approximately : 1 209 | are : 27 210 | area : 1 211 | around : 2 212 | array : 2 213 | arraying : 2 214 | arrival : 1 215 | as : 21 216 | assign : 1 217 | assigned : 6 218 | astound : 1 219 | at : 25 220 | atmosphere : 9 221 | atmospheric : 2 222 | attempting : 1 223 | back : 9 224 | bands : 2 225 | based : 1 226 | be : 24 227 | beam : 2 228 | became : 1 229 | because : 2 230 | becoming : 1 231 | been : 6 232 | before : 1 233 | began : 1 234 | behind : 1 235 | being : 3 236 | beside : 1 237 | best : 1 238 | better : 1 239 | between : 4 240 | beyond : 1 241 | biggest : 1 242 | binary : 1 243 | bit : 13 244 | bits : 10 245 | black : 8 246 | blanket : 1 247 | blended : 1 248 | blending : 1 249 | blocked : 1 250 | blue : 3 251 | bluish : 1 252 | blurred : 1 253 | board : 4 254 | body : 2 255 | both : 4 256 | bottom : 1 257 | bound : 2 258 | bright : 1 259 | brighter : 1 260 | brightness : 8 261 | broken : 1 262 | brown : 1 263 | busy : 1 264 | but : 5 265 | by : 31 266 | byte : 8 267 | bytes : 2 268 | calculating : 1 269 | call : 1 270 | called : 7 271 | came : 1 272 | camera : 5 273 | cameras : 10 274 | can : 14 275 | cannot : 1 276 | canyons : 1 277 | caps : 1 278 | carbon : 1 279 | carried : 1 280 | carries : 3 281 | carry : 1 282 | cathode : 1 283 | caused : 1 284 | cave : 1 285 | caves : 1 286 | centers : 1 287 | century : 1 288 | changing : 1 289 | character : 1 290 | charcoal : 1 291 | charting : 1 292 | chemical : 1 293 | chosen : 1 294 | circling : 2 295 | circuit : 1 296 | circulation : 3 297 | clarity : 1 298 | cliffs : 1 299 | close : 3 300 | closely : 1 301 | closest : 1 302 | closet : 1 303 | closeup : 1 304 | cloud : 1 305 | cloudtops : 4 306 | coincides : 1 307 | color : 6 308 | colored : 1 309 | colors : 1 310 | combined : 3 311 | command : 1 312 | commanded : 1 313 | common : 2 314 | compensation : 1 315 | complement : 1 316 | complete : 1 317 | complex : 2 318 | composed : 2 319 | compressing : 1 320 | compression : 1 321 | computer : 4 322 | computers : 8 323 | concentric : 1 324 | considered : 1 325 | consists : 1 326 | contact : 2 327 | contain : 1 328 | containing : 1 329 | contains : 2 330 | continued : 1 331 | continuous : 1 332 | contrast : 3 333 | control : 2 334 | controls : 2 335 | convention : 2 336 | convert : 2 337 | converting : 1 338 | converts : 1 339 | correct : 1 340 | correspond : 1 341 | correspondingly : 1 342 | corresponds : 2 343 | could : 3 344 | count : 3 345 | counted : 1 346 | counting : 3 347 | course : 1 348 | cover : 1 349 | coverage : 1 350 | covered : 1 351 | crafted : 1 352 | cratered : 2 353 | craters : 1 354 | critical : 1 355 | cup : 1 356 | currently : 1 357 | dark : 1 358 | darker : 2 359 | data : 27 360 | decrease : 1 361 | decreases : 1 362 | deep : 2 363 | deflection : 1 364 | degrees : 1 365 | dense : 1 366 | depict : 1 367 | designed : 3 368 | detail : 1 369 | detailed : 1 370 | details : 4 371 | determines : 1 372 | developed : 1 373 | devised : 1 374 | diameter : 2 375 | did : 1 376 | difference : 2 377 | differences : 2 378 | different : 1 379 | dioxide : 1 380 | direction : 2 381 | directly : 1 382 | disadvantage : 1 383 | disc : 1 384 | discerned : 2 385 | discovered : 4 386 | discoveries : 2 387 | dish : 3 388 | displayed : 1 389 | distance : 3 390 | distant : 2 391 | distinctive : 1 392 | distorting : 1 393 | distributed : 1 394 | divided : 1 395 | do : 2 396 | document : 1 397 | doing : 1 398 | done : 2 399 | dots : 4 400 | down : 1 401 | drawn : 2 402 | draws : 1 403 | drew : 1 404 | dry : 1 405 | dual : 1 406 | due : 1 407 | during : 2 408 | dweller : 1 409 | each : 12 410 | early : 1 411 | easy : 1 412 | effects : 2 413 | eight : 4 414 | either : 2 415 | ejecta : 1 416 | electrical : 1 417 | electronically : 1 418 | elements : 2 419 | eliminate : 1 420 | elsewhere : 1 421 | en : 1 422 | encircled : 1 423 | encounter : 7 424 | encounters : 1 425 | end : 2 426 | enduring : 1 427 | engineers : 2 428 | enhanced : 1 429 | enhancement : 2 430 | entered : 1 431 | enters : 2 432 | entire : 1 433 | erupting : 1 434 | etching : 1 435 | even : 4 436 | evenly : 1 437 | events : 1 438 | exaggerating : 1 439 | examination : 1 440 | examine : 1 441 | example : 3 442 | explain : 1 443 | exploration : 1 444 | exposure : 1 445 | extremely : 1 446 | eye : 4 447 | facsimile : 3 448 | facts : 1 449 | faint : 1 450 | fairly : 2 451 | falls : 1 452 | familiar : 1 453 | far : 1 454 | farther : 2 455 | fast : 1 456 | faster : 1 457 | favor : 1 458 | feat : 1 459 | featureless : 1 460 | features : 2 461 | feet : 1 462 | field : 2 463 | fields : 1 464 | filling : 1 465 | filter : 2 466 | filters : 2 467 | final : 1 468 | findings : 1 469 | fine : 1 470 | first : 13 471 | five : 2 472 | flew : 1 473 | flyby : 9 474 | flybys : 1 475 | focusing : 1 476 | fog : 1 477 | for : 21 478 | form : 1 479 | forms : 1 480 | formulating : 1 481 | found : 2 482 | foundations : 1 483 | four : 1 484 | fourth : 1 485 | frame : 1 486 | frames : 7 487 | frequently : 1 488 | from : 28 489 | ft : 3 490 | full : 4 491 | fundamental : 1 492 | future : 1 493 | fuzzy : 1 494 | gathered : 1 495 | gatherer : 1 496 | gaze : 1 497 | generated : 1 498 | generation : 2 499 | get : 2 500 | giant : 1 501 | give : 1 502 | given : 1 503 | giving : 1 504 | glass : 1 505 | globe : 1 506 | going : 1 507 | government : 1 508 | graphed : 1 509 | gravity : 2 510 | gray : 7 511 | great : 1 512 | greatly : 1 513 | green : 2 514 | greetings : 1 515 | ground : 1 516 | gyroscopes : 1 517 | had : 1 518 | halftones : 1 519 | hand : 3 520 | handicap : 1 521 | handles : 1 522 | happens : 2 523 | hardly : 1 524 | has : 8 525 | have : 17 526 | having : 1 527 | haze : 1 528 | heavens : 2 529 | heliocentric : 1 530 | here : 1 531 | high : 4 532 | higher : 1 533 | highest : 1 534 | hits : 1 535 | holds : 1 536 | hour : 2 537 | how : 1 538 | however : 2 539 | huge : 1 540 | human : 1 541 | humans : 1 542 | ice : 1 543 | if : 2 544 | illuminates : 1 545 | image : 18 546 | images : 15 547 | imagination : 1 548 | immersed : 1 549 | impact : 1 550 | impacted : 8 551 | important : 1 552 | in : 45 553 | including : 3 554 | increase : 1 555 | increased : 1 556 | increases : 1 557 | indicates : 1 558 | individual : 2 559 | information : 5 560 | instructed : 1 561 | intellect : 1 562 | intensities : 1 563 | interfere : 1 564 | intergalactic : 1 565 | intermediate : 1 566 | interplanetary : 1 567 | interpreted : 1 568 | interruption : 1 569 | intervals : 1 570 | into : 10 571 | involves : 1 572 | iron : 1 573 | is : 31 574 | isolate : 1 575 | it : 16 576 | its : 9 577 | job : 1 578 | kilometers : 1 579 | km : 2 580 | know : 1 581 | knowledge : 1 582 | known : 3 583 | landed : 5 584 | landing : 4 585 | lapse : 2 586 | large : 2 587 | largest : 2 588 | later : 1 589 | launched : 1 590 | leaving : 1 591 | left : 1 592 | lens : 1 593 | lenses : 1 594 | levels : 2 595 | lift : 1 596 | light : 8 597 | lights : 1 598 | like : 8 599 | limitation : 1 600 | limitations : 2 601 | limited : 2 602 | line : 2 603 | lines : 1 604 | linked : 1 605 | live : 1 606 | located : 2 607 | locations : 2 608 | long : 2 609 | longer : 2 610 | look : 1 611 | looked : 1 612 | looking : 1 613 | lose : 1 614 | lowest : 1 615 | lunar : 2 616 | made : 3 617 | magnetic : 3 618 | magnifying : 1 619 | making : 1 620 | managed : 1 621 | manner : 1 622 | many : 4 623 | markings : 1 624 | maximum : 1 625 | may : 1 626 | means : 2 627 | meant : 2 628 | measured : 6 629 | measurements : 2 630 | measures : 1 631 | measuring : 3 632 | medium : 2 633 | men : 1 634 | meter : 4 635 | mi : 2 636 | micrometeoroid : 1 637 | miles : 2 638 | millimeters : 1 639 | minute : 1 640 | minutes : 1 641 | mission : 1 642 | missions : 1 643 | modulated : 1 644 | month : 1 645 | moon : 4 646 | moons : 6 647 | more : 15 648 | most : 6 649 | mostly : 1 650 | motion : 1 651 | mounted : 1 652 | moved : 1 653 | movie : 1 654 | movies : 1 655 | much : 6 656 | multi : 1 657 | multiple : 1 658 | multiprobe : 1 659 | must : 3 660 | mysteries : 1 661 | mysterious : 1 662 | narrow : 1 663 | nature : 1 664 | near : 3 665 | nearly : 2 666 | needed : 1 667 | network : 1 668 | new : 9 669 | newer : 2 670 | newspaper : 1 671 | newspapers : 1 672 | next : 2 673 | night : 2 674 | nitrogen : 1 675 | no : 1 676 | noise : 1 677 | nondescript : 1 678 | normal : 1 679 | not : 5 680 | number : 2 681 | numbers : 3 682 | numerical : 2 683 | object : 4 684 | objects : 3 685 | obscured : 1 686 | obscuring : 1 687 | observing : 1 688 | occur : 1 689 | of : 125 690 | off : 2 691 | on : 41 692 | once : 1 693 | one : 16 694 | ones : 2 695 | only : 7 696 | open : 1 697 | operating : 1 698 | optical : 1 699 | or : 15 700 | orange : 3 701 | orbit : 2 702 | orbited : 2 703 | orbiting : 1 704 | order : 1 705 | origin : 1 706 | original : 1 707 | originally : 1 708 | other : 5 709 | others : 2 710 | our : 6 711 | out : 1 712 | outer : 1 713 | over : 2 714 | overcome : 3 715 | oxidized : 1 716 | pale : 1 717 | parallel : 1 718 | particles : 1 719 | passed : 1 720 | passes : 2 721 | past : 2 722 | patch : 1 723 | paths : 2 724 | pattern : 1 725 | patterns : 3 726 | payoff : 1 727 | people : 1 728 | per : 1 729 | percent : 2 730 | perceptible : 1 731 | performed : 1 732 | phases : 1 733 | photo : 1 734 | photograph : 1 735 | photographers : 1 736 | photographs : 2 737 | picture : 10 738 | pictures : 27 739 | pixel : 5 740 | pixels : 7 741 | plane : 1 742 | planes : 1 743 | planet : 18 744 | planetary : 6 745 | planets : 3 746 | plaque : 1 747 | platform : 1 748 | point : 2 749 | polar : 2 750 | portion : 2 751 | position : 2 752 | possible : 5 753 | power : 4 754 | powerful : 1 755 | precise : 1 756 | precisely : 1 757 | present : 2 758 | presently : 1 759 | previously : 1 760 | probe : 1 761 | probes : 1 762 | probing : 1 763 | process : 1 764 | produce : 1 765 | produced : 1 766 | producing : 1 767 | production : 1 768 | provide : 1 769 | provided : 2 770 | provides : 1 771 | pulses : 3 772 | pure : 2 773 | quality : 2 774 | quantity : 1 775 | questions : 1 776 | radio : 5 777 | radioed : 1 778 | radiometric : 1 779 | range : 3 780 | rapidly : 2 781 | raster : 1 782 | rate : 3 783 | rather : 2 784 | ray : 1 785 | reached : 2 786 | reaching : 2 787 | read : 2 788 | reasons : 1 789 | reassemble : 2 790 | receive : 1 791 | received : 9 792 | receiver : 2 793 | receiving : 1 794 | reception : 1 795 | reconstructed : 1 796 | recovered : 1 797 | recreate : 3 798 | red : 2 799 | reduced : 1 800 | refers : 2 801 | reflected : 1 802 | region : 1 803 | regions : 1 804 | registering : 1 805 | related : 1 806 | relayed : 2 807 | relied : 1 808 | remain : 1 809 | remained : 1 810 | renamed : 1 811 | represent : 1 812 | represented : 1 813 | represents : 3 814 | reprogrammed : 1 815 | required : 1 816 | resolution : 3 817 | resolved : 3 818 | restored : 1 819 | resulting : 2 820 | return : 1 821 | returned : 2 822 | revealed : 2 823 | revealing : 1 824 | reveals : 1 825 | righmost : 1 826 | right : 1 827 | ring : 6 828 | rings : 6 829 | rotate : 1 830 | rotates : 1 831 | rotating : 1 832 | rotation : 1 833 | route : 1 834 | rows : 1 835 | s : 22 836 | same : 3 837 | sample : 1 838 | satellite : 5 839 | satellites : 9 840 | saw : 1 841 | say : 1 842 | scanned : 2 843 | scanning : 3 844 | scatter : 2 845 | scheduled : 1 846 | scheme : 2 847 | science : 1 848 | scientists : 3 849 | scoop : 1 850 | screen : 4 851 | search : 1 852 | searching : 1 853 | second : 4 854 | seconds : 1 855 | security : 1 856 | see : 1 857 | seem : 1 858 | seen : 4 859 | selenium : 1 860 | send : 1 861 | sends : 1 862 | sensitivity : 1 863 | sensors : 4 864 | sent : 8 865 | sequence : 3 866 | set : 3 867 | several : 2 868 | shaded : 2 869 | shades : 8 870 | shaped : 2 871 | share : 1 872 | sharpening : 1 873 | shepherding : 2 874 | ship : 1 875 | shook : 1 876 | short : 1 877 | showed : 2 878 | showing : 1 879 | shown : 1 880 | shows : 1 881 | shutter : 1 882 | shutters : 1 883 | sight : 1 884 | signal : 3 885 | signals : 6 886 | similar : 2 887 | site : 1 888 | sites : 2 889 | six : 3 890 | sky : 4 891 | slight : 1 892 | slow : 1 893 | slowed : 1 894 | slower : 1 895 | slowly : 1 896 | small : 2 897 | snap : 1 898 | so : 5 899 | society : 1 900 | soft : 5 901 | soil : 1 902 | some : 1 903 | sometimes : 1 904 | sought : 1 905 | space : 13 906 | spacecraft : 24 907 | spectroscopes : 1 908 | sped : 1 909 | speeds : 1 910 | spokes : 1 911 | spread : 1 912 | square : 2 913 | squares : 1 914 | stabilizing : 1 915 | stargazer : 1 916 | stargazers : 3 917 | stars : 1 918 | startling : 1 919 | station : 3 920 | steadily : 1 921 | still : 1 922 | stone : 1 923 | storage : 1 924 | store : 1 925 | stored : 4 926 | strategy : 1 927 | stream : 1 928 | striking : 1 929 | strong : 1 930 | structure : 1 931 | studied : 2 932 | studios : 1 933 | subtle : 2 934 | successfully : 2 935 | succession : 1 936 | successive : 1 937 | such : 8 938 | sulfur : 1 939 | suppose : 1 940 | surface : 19 941 | surfaces : 1 942 | swing : 1 943 | switch : 1 944 | symbol : 1 945 | system : 7 946 | systems : 2 947 | table : 1 948 | take : 2 949 | taken : 6 950 | taking : 1 951 | tape : 2 952 | target : 2 953 | targets : 1 954 | task : 1 955 | technique : 6 956 | technology : 2 957 | telemetered : 1 958 | telemetry : 2 959 | telephoto : 1 960 | telescope : 1 961 | telescopes : 3 962 | television : 11 963 | temporarily : 2 964 | th : 1 965 | than : 12 966 | that : 22 967 | the : 207 968 | their : 6 969 | them : 5 970 | then : 6 971 | theories : 1 972 | there : 1 973 | thereby : 1 974 | they : 8 975 | thin : 1 976 | this : 5 977 | those : 5 978 | thought : 1 979 | thousand : 1 980 | thousands : 1 981 | three : 9 982 | through : 9 983 | tilted : 2 984 | time : 4 985 | times : 3 986 | tiniest : 1 987 | tiny : 2 988 | to : 82 989 | today : 1 990 | together : 1 991 | tone : 1 992 | tones : 1 993 | too : 1 994 | took : 3 995 | tools : 2 996 | top : 1 997 | topography : 1 998 | total : 3 999 | track : 2 1000 | tracked : 1 1001 | tracking : 3 1002 | trajectory : 2 1003 | translation : 1 1004 | transmission : 3 1005 | transmit : 2 1006 | transmitted : 7 1007 | transmitting : 2 1008 | transparent : 1 1009 | travel : 1 1010 | traveled : 1 1011 | traveling : 1 1012 | true : 1 1013 | tube : 5 1014 | twenty : 1 1015 | twice : 1 1016 | two : 6 1017 | typically : 1 1018 | ultraviolet : 1 1019 | unaided : 3 1020 | unblurred : 1 1021 | under : 1 1022 | understand : 1 1023 | unexplored : 1 1024 | unfolded : 1 1025 | unit : 3 1026 | universe : 2 1027 | unknown : 2 1028 | unmanned : 1 1029 | unprecedented : 1 1030 | until : 4 1031 | up : 4 1032 | us : 1 1033 | use : 3 1034 | used : 5 1035 | useful : 1 1036 | using : 1 1037 | vacuum : 1 1038 | valleys : 1 1039 | value : 11 1040 | values : 10 1041 | various : 3 1042 | variously : 1 1043 | vary : 1 1044 | varying : 1 1045 | ventured : 1 1046 | verified : 1 1047 | very : 3 1048 | vicinity : 1 1049 | vidicon : 2 1050 | view : 3 1051 | visited : 1 1052 | visual : 2 1053 | volcanic : 1 1054 | volcano : 1 1055 | volcanoes : 2 1056 | wanderers : 1 1057 | was : 11 1058 | waves : 1 1059 | way : 3 1060 | ways : 1 1061 | we : 2 1062 | well : 2 1063 | were : 12 1064 | what : 3 1065 | when : 6 1066 | where : 2 1067 | whereas : 1 1068 | which : 5 1069 | while : 5 1070 | white : 8 1071 | whose : 1 1072 | wide : 1 1073 | will : 6 1074 | with : 18 1075 | within : 2 1076 | without : 1 1077 | women : 1 1078 | wonder : 1 1079 | work : 1 1080 | works : 1 1081 | world : 1 1082 | would : 4 1083 | wrong : 1 1084 | x : 1 1085 | yearning : 1 1086 | years : 1 1087 | you : 3 1088 | zero : 2 -------------------------------------------------------------------------------- /Chapter05/sets.jl: -------------------------------------------------------------------------------- 1 | s = Set([11, 14, 13, 7, 14, 11]) 2 | #> Set([7, 14, 13, 11]) 3 | 4 | # empty set: 5 | Set() #> Set(Any[]) 6 | 7 | s1 = Set([11, 25]) 8 | s2 = Set([25, 3.14]) 9 | union(s1, s2) #> Set([3.14, 25.0, 11.0]) 10 | intersect(s1, s2) #> Set([25]) 11 | setdiff(s1, s2) #> Set([11]) 12 | setdiff(s2, s1) #> Set([3.14]) 13 | issubset(s1, s2) #> false 14 | issubset(s1, Set([11, 25, 36])) #> true 15 | 16 | push!(s1, 32) #> Set([25,32,11]) 17 | in(32, s1) #> true 18 | in(100, s1) #> false 19 | 20 | s1 = Set([1,2,3]) #> Set([2,3,1]) 21 | typeof(s1) #> Set{Int64} 22 | Set([[1,2,3]]) #> Set(Array{Int64,1}[[1, 2, 3]]) 23 | 24 | x = Set(collect(1:100)) 25 | @time 2 in x 26 | #> 0.003186 seconds (33 allocations: 2.078 KiB) 27 | x2 = Set(collect(1:1000000)) 28 | @time 2 in x2 29 | # 0.000003 seconds (4 allocations: 160 bytes) 30 | -------------------------------------------------------------------------------- /Chapter05/tuples.jl: -------------------------------------------------------------------------------- 1 | a, b, c, d = 1, 22.0, "World", 'x' 2 | a #> 1 3 | b #> 22.0 4 | c #> "World" 5 | d #> 'x' 6 | t1 = (1,22.0,"World",'x') 7 | typeof(t1) #> Tuple{Int64,Float64,String,Char} 8 | t2 = (1, 2, 3) 9 | typeof(t2) #> Tuple{Int64,Int64,Int64} 10 | () #> empty tuple 11 | (1,) #> one element tuple 12 | ('z', 3.14)::Tuple{Char, Float64} 13 | 14 | t3 = (5, 6, 7, 8) 15 | t3[1] #> 5 16 | t3[end] #> 8 17 | t3[2:3] #> (6, 7) 18 | # t3[5] #> BoundsError 19 | # t3[3] = 9 #> Error: 'setindex' has no matching ... 20 | 21 | author = ("Ivo", "Balbaert", 62) 22 | author[2] #> "Balbaert" 23 | 24 | for i in t3 25 | println(i) 26 | end #> 5 6 7 8 27 | 28 | #tuple unpacking: 29 | a, b = t3 #> a is 5 and b is 6 30 | first_name, last_name, age = author 31 | # first_name has value "Ivo" 32 | # last_name has value "Balbaert" 33 | # age has value 62 -------------------------------------------------------------------------------- /Chapter05/word_frequency.jl: -------------------------------------------------------------------------------- 1 | # 1- read in text file: 2 | str = read("words1.txt", String) 3 | # println(str) #> to be or not to be that is the question 4 | # 2- replace non alphabet characters and digits from text with a space: 5 | nonalpha = r"(\W\s?)" 6 | str = replace(str, nonalpha => ' ') 7 | digits = r"(\d+)" 8 | str = replace(str, digits => ' ') 9 | #> "to be or not to be that is the question " 10 | # 3- split text in words: 11 | word_list = split(str, ' ') 12 | # println(word_list) 13 | #> "to" "be" "or" "not" "to" "be" "that" "is" "the" "question" "" 14 | # 4- make a dictionary with the words and count their frequencies: 15 | word_freq = Dict{String, Int64}() 16 | for word in word_list 17 | word = strip(word) 18 | if isempty(word) continue end 19 | haskey(word_freq, word) ? 20 | word_freq[word] += 1 : 21 | word_freq[word] = 1 22 | end 23 | # 5- sort the words (the keys) and print out the frequencies: 24 | println("Word : frequency \n") 25 | words = sort!(collect(keys(word_freq))) 26 | for word in words 27 | println("$word : $(word_freq[word])") 28 | end -------------------------------------------------------------------------------- /Chapter05/words1.txt: -------------------------------------------------------------------------------- 1 | to be, or not to be, that is the question! -------------------------------------------------------------------------------- /Chapter05/words2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-1.0-Programming-Second-Edition/0c2aae68db4b40a919f9d3d604b1df73a1bf85b2/Chapter05/words2.txt -------------------------------------------------------------------------------- /Chapter06/conversions.jl: -------------------------------------------------------------------------------- 1 | # (31+42)::Float64 #> TypeError(:typeassert,"",Float64,73) 2 | # convert(Int64, 7.01) #> ERROR: InexactError() 3 | convert(Int64, 7.0) #> 7 4 | Int64(7.0) #> 7 5 | # Int64(7.01) #> ERROR: InexactError: Int64(Int64, 7.01) 6 | # convert(Int64, "CV") 7 | # ERROR: MethodError: Cannot `convert` an object of type String to an object of type Int64 8 | # convert(Int64, "123") # same ERROR as above 9 | 10 | promote(1, 2.5, 3//4) #> (1.0,2.5,0.75) 11 | promote(1.5, im) #> (1.5 + 0.0im,0.0 + 1.0im) 12 | promote(true, 1.0) #> (1.0, 1.0) 13 | promote_type(Int8, UInt16) #> UInt16 -------------------------------------------------------------------------------- /Chapter06/file1.jl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-1.0-Programming-Second-Edition/0c2aae68db4b40a919f9d3d604b1df73a1bf85b2/Chapter06/file1.jl -------------------------------------------------------------------------------- /Chapter06/file2.jl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-1.0-Programming-Second-Edition/0c2aae68db4b40a919f9d3d604b1df73a1bf85b2/Chapter06/file2.jl -------------------------------------------------------------------------------- /Chapter06/inner_constructors.jl: -------------------------------------------------------------------------------- 1 | mutable struct Person 2 | firstname::String 3 | lastname::String 4 | sex::Char 5 | age::Float64 6 | children::Array{String, 1} 7 | end 8 | 9 | p1 = Person("Alan", "Bates", 'M', 45.5, ["Jeff", "Stephan"]) 10 | #> Person("Alan", "Bates",'M',45.5,String["Jeff","Stephan"]) 11 | 12 | people = Person[] #> 0-element Array{Person,1} 13 | push!(people, p1) #> 1-element Array{Person,1}: 14 | #Person("Alan", "Bates", 'M', 45.5, ["Jeff", "Stephan"]) 15 | push!(people, Person("Julia", "Smith", 'F', 27, ["Viral"])) 16 | 17 | show(people) 18 | #> Person[Person("Alan", "Bates", 'M', 45.5, ["Jeff", "Stephan"]), 19 | # Person("Julia", "Smith", 'F', 27.0, ["Viral"])] 20 | 21 | fullname(p::Person) = "$(p.firstname) $(p.lastname)" 22 | fullname(p::Person) = string(p.firstname, " ", p.lastname) 23 | print(fullname(p1)) #> Alan Bates 24 | 25 | mutable struct Family 26 | name::String 27 | members::Array{String, 1} 28 | big::Bool 29 | Family(name::String) = new(name, String[], false) 30 | Family(name::String, members) = new(name, members, length(members) > 4) 31 | end 32 | 33 | fam = Family("Bates-Smith", ["Alan", "Julia", "Jeff", "Stephan", "Viral"]) 34 | #> Family("Bates-Smith",String["Alan","Julia","Jeff","Stephan","Viral"],true) -------------------------------------------------------------------------------- /Chapter06/modules.jl: -------------------------------------------------------------------------------- 1 | module Package1 2 | 3 | export Type1, perc 4 | 5 | include("file1.jl") 6 | include("file2.jl") 7 | 8 | # code 9 | mutable struct Type1 10 | total 11 | end 12 | 13 | perc(a::Type1) = a.total * 0.01 14 | 15 | end -------------------------------------------------------------------------------- /Chapter06/parametric.jl: -------------------------------------------------------------------------------- 1 | mutable struct Point{T} 2 | x::T 3 | y::T 4 | end 5 | 6 | Point{Int64} #> Point{Int64} (constructor with 1 method) 7 | Point{Float64} #> Point{Float64} (constructor with 1 method) 8 | Point{String} #> Point{String} (constructor with 1 method) 9 | 10 | Point{Int64} <: Point #> true 11 | Point{String} <: Point #> true 12 | Point{Float64} <: Point{Real} #> false 13 | 14 | p = Point{Int64}(2, 5) #> Point{Int64}(2,5) 15 | p = Point(2, 5) #> Point{Int64}(2,5) 16 | p = Point("London", "Great-Britain") #> Point{String}("London", "Great-Britain") 17 | 18 | mutable struct PointP{T <: Real} 19 | x::T 20 | y::T 21 | end 22 | 23 | # p = PointP("London", "Great-Britain") #> ERROR: MethodError: no method matching PointP(::String, ::String) 24 | 25 | add(x::T, y::T) where T = x + y 26 | add(2, 3) #> 5 27 | # add(2, 3.0) #> ERROR: MethodError: `add` has no method matching add(::Int64, ::Float64) 28 | add(x::T, y::T) where T <: Number = x + y 29 | 30 | function vecfloat(x::Vector{T}) where T <: AbstractFloat 31 | # code 32 | end -------------------------------------------------------------------------------- /Chapter06/temperature_converter.jl: -------------------------------------------------------------------------------- 1 | module TemperatureConverter 2 | 3 | function as_celsius(temperature, unit) 4 | if unit == :Celsius 5 | return temperature 6 | elseif unit == :Kelvin 7 | return kelvin_to_celsius(temperature) 8 | end 9 | end 10 | 11 | function kelvin_to_celsius(temperature) 12 | # 'private' function 13 | return temperature + 273 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /Chapter06/type_hierarchy.jl: -------------------------------------------------------------------------------- 1 | typeof(2) #> Int64 2 | typeof(Int64) #> DataType 3 | typeof(Complex{Int64}) #> DataType 4 | typeof(Any) #> DataType 5 | typeof(DataType) #> DataType 6 | 7 | supertype(Int64) #> Signed 8 | supertype(Signed) #> Integer 9 | supertype(Integer) #> Real 10 | supertype(Real) #> Number 11 | supertype(Number) #> Any 12 | supertype(Any) #> Any 13 | 14 | using InteractiveUtils 15 | subtypes(Integer) #> 3-element Array{Any,1}: 16 | # Bool 17 | # Signed 18 | # Unsigned 19 | subtypes(Signed) #> 6-element Array{Any,1}: 20 | # BigInt 21 | # Int128 22 | # Int16 23 | # Int32 24 | # Int64 25 | # Int8 26 | subtypes(Int64) #> 0-element Array{Any,1} 27 | typeof(Nothing) #> DataType 28 | 29 | Bool <: Integer #> true 30 | Bool <: Any #> true 31 | Bool <: Char #> false 32 | Bool <: Integer #> true 33 | Float64 <: Integer #> false 34 | 35 | typeof(5) #> Int64 36 | isa(5, Number) #> true -------------------------------------------------------------------------------- /Chapter06/unions.jl: -------------------------------------------------------------------------------- 1 | mutable struct Point 2 | x::Float64 3 | y::Float64 4 | end 5 | 6 | mutable struct Vector2D 7 | x::Float64 8 | y::Float64 9 | end 10 | 11 | p = Point(2, 5) #> Point(2.0,5.0) 12 | v = Vector2D(3, 2) #> Vector2D(3.0,2.0) 13 | 14 | # Example with sum: 15 | # +(p, v) #> MethodError: ERROR: `+` has no method matching +(::Point, ::Vector2D) 16 | 17 | import Base.+ 18 | +(p::Point, q::Point) = Point(p.x + q.x, p.y + q.y) 19 | +(u::Vector2D, v::Vector2D) = Point(u.x + v.x, u.y + v.y) 20 | +(u::Vector2D, p::Point) = Point(u.x + p.x, u.y + p.y) 21 | # +(p, v) #> ERROR: MethodError: `+` has no method matching +(::Point, ::Vector2D) 22 | +(p::Point, v::Vector2D) = Point(p.x + v.x, p.y + v.y) 23 | +(p, v) #> Point(5.0,7.0) 24 | 25 | # Example with dot product: 26 | # *(p, v) #> ERROR: MethodError: `*` has no method matching *(::Point, ::Vector2D) 27 | 28 | import Base.* 29 | *(p::Point, q::Point) = p.x * q.x + p.y * q.y 30 | *(u::Vector2D, v::Vector2D) = u.x * v.x + u.y * v.y 31 | *(u::Vector2D, p::Point) = u.x * p.x + u.y * p.y 32 | # *(p, v) #> ERROR: MethodError: `*` has no method matching *(::Point, ::Vector2D) 33 | *(p::Point, v::Vector2D) = p.x * v.x + p.y * v.y 34 | *(p, v) #> 16.0 35 | 36 | VecOrPoint = Union{Vector2D, Point} 37 | 38 | isa(p, VecOrPoint) #> true 39 | isa(v, VecOrPoint) #> true 40 | 41 | +(u::VecOrPoint, v:: VecOrPoint) = Point(u.x + v.x, u.y + v.y) #> or typeof(u)(u.x + v.x, u.y + v.y) to vary the return type 42 | +(p, v) #> Point(5.0,7.0) 43 | 44 | *(u::VecOrPoint, v:: VecOrPoint) = u.x * v.x + u.y * v.y 45 | *(p, v) #> 16.0 -------------------------------------------------------------------------------- /Chapter06/user_defined.jl: -------------------------------------------------------------------------------- 1 | using InteractiveUtils 2 | 3 | mutable struct Point 4 | x::Float64 5 | y::Float64 6 | z::Float64 7 | end 8 | 9 | typeof(Point) #> DataType 10 | 11 | fieldnames(Point) #> (:x, :y, :z) 12 | 13 | orig = Point(0, 0, 0) #> Point(0.0,0.0,0.0) 14 | p1 = Point(2, 4, 1.3) #> Point(2.0,4.0,1.3) 15 | fieldnames(typeof(p1)) #> (:x, :y, :z) 16 | 17 | methods(Point) 18 | # 3 methods for generic function "(::Type)": 19 | # [1] Point(x::Float64, y::Float64, z::Float64) in Main at REPL[12]:2 20 | # [2] Point(x, y, z) in Main at REPL[12]:2 21 | # [3] (::Type{T})(arg) where T in Base at deprecated.jl:461 22 | 23 | typeof(p1) #> Point (constructor with 1 method) 24 | subtypes(Point) #> 0-element Array{Type,1} 25 | 26 | p1.y #> 4.0 27 | p1.z = 3.14 #> 3.14 28 | p1 #> Point(2.0, 4.0, 3.14) 29 | # p1.z = "A" #> ERROR: MethodError: Cannot `convert` an object of type String 30 | # to an object of type Float64 31 | 32 | struct Vector3D 33 | x::Float64 34 | y::Float64 35 | z::Float64 36 | end 37 | typeof(Vector3D) #> DataType 38 | p = Vector3D(1, 2, 3) #> Vector3D(1.0,2.0,3.0) 39 | # p.y = 5 #> ERROR: type Vector3D is immutable 40 | 41 | Point3D = Point 42 | p31 = Point3D(1, 2, 3) #> Point(1.0,2.0,3.0) 43 | 44 | 5 == 5 #> true 45 | 5 == 5.0 #> true 46 | isequal(5, 5) #> true 47 | isequal(5, 5.0) #> true 48 | 5 === 5 #> true 49 | 5 === 5.0 #> false 50 | 51 | q = Vector3D(4.0, 3.14, 2.71) 52 | r = Vector3D(4.0, 3.14, 2.71) 53 | isequal(q, r) #> true 54 | q === r #> true 55 | 56 | mutable struct MVector3D 57 | x::Float64 58 | y::Float64 59 | z::Float64 60 | end 61 | 62 | q = MVector3D(4.0, 3.14, 2.71) 63 | r = MVector3D(4.0, 3.14, 2.71) 64 | isequal(q, r) #> false 65 | q === r #> false 66 | 67 | # constructors, subtyping and multiple dispatch 68 | abstract type Employee 69 | end 70 | 71 | # Employee() #> ERROR: MethodError: no constructors have been defined for Employee 72 | 73 | mutable struct Developer <: Employee 74 | name::String 75 | iq 76 | favorite_lang 77 | end 78 | 79 | # mutable struct MobileDeveloper <: Developer 80 | # platform 81 | # end 82 | # ERROR: invalid subtyping in definition of MobileDeveloper 83 | 84 | # outer constructor: 85 | Developer(name, iq) = Developer(name, iq, "Java") 86 | #> Developer (constructor with 3 methods) 87 | 88 | mutable struct Manager 89 | name::String 90 | iq 91 | department::String 92 | end 93 | 94 | devel1 = Developer("Bob", 110) #> Developer("Bob",110,"Java") 95 | devel2 = Developer("William", 145, "Julia") 96 | #> Developer("William",145,"Julia") 97 | man1 = Manager("Julia", 120, "ICT") #> Manager("Julia",120,"ICT") 98 | 99 | cleverness(emp::Employee) = emp.iq 100 | cleverness(devel1) #> 110 101 | # cleverness(man1) #> ERROR: MethodError: `cleverness` has no method 102 | # matching cleverness(::Manager) 103 | 104 | function cleverer(m::Manager, e::Employee) 105 | println("The manager $(m.name) is cleverer!") 106 | end 107 | 108 | cleverer(man1, devel1) #> The manager Julia is cleverer! 109 | cleverer(man1, devel2) #> The manager Julia is cleverer! 110 | 111 | function cleverer(d::Developer, e::Employee) 112 | println("The developer $(d.name) is cleverer!") 113 | end 114 | 115 | cleverer(devel1, devel2) #> The developer Bob is cleverer! 116 | # cleverer(devel1, man1) #> ERROR: `cleverer` has no method matching cleverer(::Developer,::Manager) 117 | 118 | function cleverer(e::Employee, d::Developer) 119 | if e.iq <= d.iq 120 | println("The developer $(d.name) is cleverer!") 121 | else 122 | println("The employee $(e.name) is cleverer!") 123 | end 124 | end 125 | 126 | # cleverer(devel1, devel2) 127 | #> ERROR: MethodError: cleverer(::Developer, ::Developer) is ambiguous. Candidates: 128 | # cleverer(e::Employee, d::Developer) in Main at REPL[32]:2 129 | # cleverer(d::Developer, e::Employee) in Main at REPL[29]:2 130 | # Possible fix, define 131 | # cleverer(::Developer, ::Developer) 132 | 133 | function cleverer(d1::Developer, d2::Developer) 134 | if d1.iq <= d2.iq 135 | println("The developer $(d2.name) is cleverer!") 136 | else 137 | println("The developer $(d1.name) is cleverer!") 138 | end 139 | end 140 | 141 | cleverer(devel1, devel2) #> The developer William is cleverer! 142 | cleverer(devel2, devel1) #> The developer William is cleverer! -------------------------------------------------------------------------------- /Chapter06/using_module.jl: -------------------------------------------------------------------------------- 1 | include("temperature_converter.jl") 2 | 3 | println("$(TemperatureConverter.as_celsius(100, :Celsius))") #> 100 4 | println("$(TemperatureConverter.as_celsius(100, :Kelvin))") #> 373 5 | println("$(TemperatureConverter.kelvin_to_celsius(0))") #> 273 -------------------------------------------------------------------------------- /Chapter07/built_in_macros.jl: -------------------------------------------------------------------------------- 1 | # Testing: 2 | # @assert 1==42 "Shouldn't this be so?" 3 | #> ERROR: assertion failed: Shouldn't this be so? 4 | 5 | using Test 6 | # @test 1==3 7 | #> 8 | # Test Failed at REPL[5]:1 9 | # Expression: 1 == 3 10 | # Evaluated: 1 == 3 11 | # ERROR: There was an error during testing. 12 | 13 | # @test 1 ≈ 1.1 14 | # Test Failed at REPL[58]:1 15 | # Expression: 1 ≈ 1.1 16 | # Evaluated: 1 ≈ 1.1 17 | # ERROR: There was an error during testing 18 | @test 1 ≈ 1.1 atol=0.2 #> Test Passed 19 | 20 | # Debugging: 21 | using InteractiveUtils # for @which 22 | arr = [1, 2] #> 2-element Array{Int64,1}: 1 2 23 | @which sort(arr) 24 | #> sort(v::AbstractArray{T,1} where T) in Base.Sort at sort.jl:683 25 | 456 * 789 + (@show 2 + 3) #> 2 + 3 => 5 359789 26 | 27 | # Benchmarking: 28 | @time [x^2 for x in 1:1000] #> elapsed time: 3.911e-6 seconds (8064 bytes allocated) # 1000-element Array{Int64,1}: … 29 | @timed [x^2 for x in 1:1000] 30 | #> ([1,4,9,16,25,36,49,64,81,100 … 982081,984064,986049,988036,990025,992016,9940 31 | # 09,996004,998001,1000000],3.911e-6,8064,0.0) 32 | @elapsed [x^2 for x in 1:1000] #> 3.422e-6 33 | @allocated [x^2 for x in 1:1000] #> 8064 34 | 35 | # starting a task: 36 | a = @async 1 + 2 37 | # Task (done) @0x000000002d70faf0 38 | -------------------------------------------------------------------------------- /Chapter07/eval.jl: -------------------------------------------------------------------------------- 1 | e1 = Expr(:call, *, 3, 4) #> :((*)(3,4)) 2 | eval(e1) #> 12 3 | 4 | # e1 = Expr(:call, *, 3, a) #> ERROR: UndefVarError: a not defined 5 | e2 = Expr(:call, *, 3, :a) #> :((*)(3,a)) 6 | # eval(e2) #> ERROR: UndefVarError: a not defined 7 | a = 4 #> 4 8 | eval(e2) #> 12 9 | 10 | # b #> ERROR: UndefVarError: b not defined 11 | e3 = :(b = 1) 12 | eval(e3) #> 1 13 | b #> 1 14 | 15 | e4 = :(a + b) #> :(a + b) 16 | e5 = :($a + b) #> :(4 + b) 17 | eval(e4) #> 5 18 | eval(e5) #> 5 -------------------------------------------------------------------------------- /Chapter07/expressions.jl: -------------------------------------------------------------------------------- 1 | typeof(2 + 3) #> Int64 2 | :(2 + 3) #> :(2 + 3) 3 | typeof(:(2 + 3)) #> Expr 4 | 5 | quote 6 | a = 42 7 | b = a^2 8 | a - b 9 | end 10 | # quote # none, line 2: 11 | # a = 42 # line 3: 12 | # b = a^2 # line 4: 13 | # a - b 14 | # end 15 | :(a = 42; b = a^2; a - b) 16 | # returns: 17 | # quote 18 | # a = 42 19 | # begin 20 | # b = a^2 21 | # a - b 22 | # end 23 | # end 24 | 25 | e1 = :(2 + 3) 26 | e1.head #> :call 27 | e1.args #> 3-element Array{Any,1}: :+ 2 3 28 | 2 + 3 == +(2, 3) #> true 29 | 30 | e2 = :(2 + a * b - c) 31 | e2.args #> 3-element Array{Any,1}: :- :(2 + a * b) :c 32 | :(2 + a * b).args #> 3-element Array{Any,1}: :+ 2 :(a * b) 33 | :(a * b).args #> 3-element Array{Any,1}: :* :a :b 34 | 35 | x = 5 #> 5 36 | :x #> :x 37 | 38 | dump(:(2 + 2)) 39 | # Expr 40 | # head: Symbol call 41 | # args: Array(Any,(3,)) 42 | # 1: Symbol + 43 | # 2: Int64 2 44 | # 3: Int64 2 45 | 46 | dump(:(2 + a * b - c)) 47 | # Expr 48 | # head: Symbol call 49 | # args: Array(Any,(3,)) 50 | # 1: Symbol - 51 | # 2: Expr 52 | # head: Symbol call 53 | # args: Array(Any,(3,)) 54 | # 1: Symbol + 55 | # 2: Int64 2 56 | # 3: Expr 57 | # head: Symbol call 58 | # args: Array(Any,(3,)) 59 | # typ: Any 60 | # typ: Any 61 | # 3: Symbol c -------------------------------------------------------------------------------- /Chapter07/macros.jl: -------------------------------------------------------------------------------- 1 | # Example 1: 2 | macro macint(ex) 3 | quote 4 | println("start") 5 | $ex 6 | println("after") 7 | end 8 | end 9 | 10 | @macint println("Where am I?") 11 | #start 12 | #Where am I? 13 | #after 14 | 15 | # Example 2: 16 | macro duplicate(ex) 17 | quote 18 | $ex 19 | $ex 20 | end 21 | end 22 | 23 | @duplicate println(sin(42)) 24 | # -0.9165215479156338 25 | # -0.9165215479156338 26 | 27 | # Example 3: 28 | macro assert(ex) 29 | :($ex ? nothing : error("Assertion failed: ", $(string(ex)))) 30 | end 31 | 32 | @assert 1 == 1.0 33 | # @assert 1 == 42 #> ERROR: Assertion failed: 1 == 42 34 | 35 | # Example 4: 36 | macro unless(test_cond, branch) 37 | quote 38 | if !$test_cond 39 | $branch 40 | end 41 | end 42 | end 43 | 44 | arr = [3.14, 42, 'b'] 45 | @unless 41 in arr println("arr does not contain 41") 46 | #> array does not contain 41 47 | @unless 42 in arr println("arr does not contain 42") #> nothing 48 | @unless isempty(arr) println("array arr has elements") 49 | #> array arr has elements 50 | 51 | macroexpand(Main, :(@unless 41 in arr println("arr does not contain 41")) ) 52 | # quote 53 | # #= REPL[15]:3 =# 54 | # if !(41 in Main.arr) 55 | # #= REPL[15]:4 =# 56 | # (Main.println)("arr does not contain 41") 57 | # end 58 | # end 59 | 60 | # Example 5: 61 | @time factorial(10) 62 | #> 0.023171 seconds (15.36 k allocations: 797.196 KiB) 63 | # 3628800 64 | 65 | using Printf 66 | macro timeit(ex) 67 | quote 68 | local t0 = time() # local necessary to not conflict with outside 69 | local val = $(esc(ex)) # variables; esc makes sure ex is not 70 | local t1 = time() # expanded, but is used literally 71 | print("elapsed time in seconds: ") 72 | @printf "%.3f" t1 - t0 73 | val 74 | end 75 | end 76 | 77 | @timeit factorial(10) #> elapsed time in seconds: 0.0003628800 78 | @timeit factorial(15) #> elapsed time in seconds: 0.0001307674368000 79 | a = 42 80 | @timeit a^3 #> elapsed time in seconds: 0.00074088 81 | 82 | # Example 6: 83 | using Statistics 84 | macro bench(f) 85 | quote 86 | median([@elapsed sleep($f) for x=1:10]) 87 | end 88 | end 89 | 90 | @bench 0.1 #> 0.1010291465 91 | @bench 0.2 #> 0.20101891449999998 92 | @bench 0.5 #> 0.501034175 -------------------------------------------------------------------------------- /Chapter07/reflection.jl: -------------------------------------------------------------------------------- 1 | mutable struct Person 2 | name:: String 3 | height::Float64 4 | end 5 | 6 | fieldnames(Person) #> (:name, :height) 7 | Person.types #> svec(String, Float64) 8 | 9 | code_lowered(+, (Int, Int)) 10 | # 1-element Array{Core.CodeInfo,1}: 11 | # CodeInfo( 12 | # 53 1 ─ %1 = Base.add_int(%%x, %%y)::Any │ 13 | # └── return %1 │ 14 | # ) 15 | 16 | code_typed(+, (Int, Int)) 17 | # 1-element Array{Any,1}: 18 | # CodeInfo( 19 | # 53 1 ─ %1 = Base.add_int(%%x, %%y)::Int64 │ 20 | # └── return %1 │ 21 | # ) => Int64 -------------------------------------------------------------------------------- /Chapter08/csv_files.jl: -------------------------------------------------------------------------------- 1 | fname = "winequality.csv" 2 | 3 | using DelimitedFiles 4 | data = DelimitedFiles.readdlm(fname, ';') 5 | # 1600x12 Array{Any,2}: 6 | # "fixed acidity" "volatile acidity" … "alcohol" "quality" 7 | # 7.4 0.7 9.4 5.0 8 | # 7.8 0.88 9.8 5.0 9 | # 7.8 0.76 9.8 5.0 10 | # 11.2 0.28 9.8 6.0 11 | 12 | # variant: 13 | data3 = DelimitedFiles.readdlm(fname, ';', Float64, '\n', header=true) 14 | #> ([7.4 0.7 … 9.4 5.0; 7.8 0.88 … 9.8 5.0; … ; 5.9 0.645 … 10.2 5.0; 15 | # 6.0 0.31 … 11.0 6.0], 16 | # AbstractString["fixed acidity" "volatile acidity" … "alcohol" "quality"]) 17 | 18 | # extracting data: 19 | row3 = data[3, :] # measurements for wine xyz 20 | # 12-element Array{Any,1}: 7.8 0.88 0 2.6 0.098 25 67 0.9968 3.2 0.68 9.8 5 21 | col3 = data[ :, 3] # measurements of citric acid 22 | # 1600-element Array{Any,1}: 23 | # "citric acid" 24 | # 0.0 0.0 0.04 0.56 0.0 0.0 ⋮ 0.08 0.08 0.1 0.13 0.12 0.47 ... 25 | x = data[:, 2:4] 26 | # 1600×3 Array{Any,2}: 27 | # "volatile acidity" "citric acid" "residual sugar" 28 | # 0.7 0 1.9 29 | # 0.88 0 2.6 30 | # 0.76 0.04 2.3 31 | y = data[70:75, 2:4] 32 | # 6x3 Array{Any,2}: 33 | # 0.32 0.57 2.0 34 | # 0.705 0.05 1.9 35 | # 0.63 0.08 1.9 36 | # 0.67 0.23 2.1 37 | # 0.69 0.22 1.9 38 | # 0.675 0.26 2.1 39 | z = [data[:,3] data[:,6] data[:,11]] 40 | # 1600x3 Array{Any,2}: 41 | # "citric acid" "free sulfur dioxide" "alcohol" 42 | # 0.0 11.0 9.4 43 | # 0.0 25.0 9.8 44 | # 0.04 15.0 9.8 45 | # 0.56 17.0 9.8 46 | # ⋮ 47 | # 0.08 32.0 10.5 48 | # 0.1 39.0 11.2 49 | # 0.13 29.0 11.0 50 | # 0.12 32.0 10.2 51 | # 0.47 18.0 11.0 52 | 53 | # without headers: 54 | z = [data[2:end,3] data[2:end,6] data[2:end,11]] 55 | 56 | mutable struct Wine 57 | fixed_acidity::Array{Float64} 58 | volatile_acidity::Array{Float64} 59 | citric_acid::Array{Float64} 60 | #...define the other columns here 61 | quality::Array{Float64} 62 | end 63 | # wine1 = Wine(7.4, 0.7, 0, ..., 5) 64 | # wine1 = Wine(data[1, :]...) # ... = splat-operator 65 | 66 | data = z 67 | # writing to csv file: 68 | writedlm("partial.dat", data, ';') -------------------------------------------------------------------------------- /Chapter08/dataframes.jl: -------------------------------------------------------------------------------- 1 | using DataFrames, Missings, CSV 2 | 3 | # constructing a DataFrame: 4 | df = DataFrame() 5 | df[:Col1] = 1:4 6 | df[:Col2] = [exp(1), pi, sqrt(2), 42] 7 | df[:Col3] = [true, false, true, false] 8 | show(df) 9 | # 4x3 DataFrame 10 | # | Row | Col1 | Col2 | Col3 | 11 | # |-----|------|---------|-------| 12 | # | 1 | 1 | 2.71828 | true | 13 | # | 2 | 2 | 3.14159 | false | 14 | # | 3 | 3 | 1.41421 | true | 15 | # | 4 | 4 | 42.0 | false | 16 | 17 | df = DataFrame(Col1 = 1:4, Col2 = [exp(1), pi, sqrt(2), 42], Col3 = [true, false, true, false]) 18 | 19 | # columns: 20 | show(df[2]) 21 | #> [2.718281828459045,3.141592653589793,1.4142135623730951,42.0] 22 | show(df[:Col2]) #> same output 23 | 24 | # rows: 25 | show(df[1, :]) #> 1st row 26 | # 1x3 DataFrame 27 | # | Row | Col1 | Col2 | Col3 | 28 | # |-----|------|---------|------| 29 | # | 1 | 1 | 2.71828 | true | 30 | show(df[2:3, :]) #> 2nd and 3rd row: 31 | # 2x3 DataFrame 32 | # | Row | Col1 | Col2 | Col3 | 33 | # |-----|------|---------|-------| 34 | # | 1 | 2 | 3.14159 | false | 35 | # | 2 | 3 | 1.41421 | true | 36 | show(df[2:3, :Col2]) #> 2nd and 3rd row, only 2nd column: 37 | # [3.141592653589793,1.4142135623730951] 38 | df[2:3, [:Col2, :Col3]] #> 2nd and 3rd row, 2nd and 3rd column: 39 | # 2x2 DataFrame 40 | # | Row | Col2 | Col3 | 41 | # |-----|---------|-------| 42 | # | 1 | 3.14159 | false | 43 | # | 2 | 1.41421 | true | 44 | head(df) 45 | 46 | df0 = DataFrame(i = 1:10, x = rand(10), y = rand(["a", "b", "c"], 10)) 47 | head(df0) 48 | 49 | tail(df) 50 | 51 | names(df) 52 | # 3-element Array{Symbol,1}: 53 | # :Col1 54 | # :Col2 55 | # :Col3 56 | eltypes(df) 57 | # 3-element Array{Type{T<:Top},1}: 58 | # Int64 59 | # Float64 60 | # Bool 61 | 62 | describe(df) 63 | # 3×8 DataFrame 64 | # │ Row │ variable │ mean │ min │ median │ max │ nunique │ nmissing │ eltype │ 65 | # ├─────┼──────────┼─────────┼─────────┼─────────┼──────┼─────────┼──────────┼─────────┤ 66 | # │ 1 │ Col1 │ 2.5 │ 1 │ 2.5 │ 4 │ │ │ Int64 │ 67 | # │ 2 │ Col2 │ 12.3185 │ 1.41421 │ 2.92994 │ 42.0 │ │ │ Float64 │ 68 | # │ 3 │ Col3 │ 0.5 │ false │ 0.5 │ true │ │ │ Bool │ 69 | 70 | fname = "winequality.csv" 71 | data = CSV.read(fname, delim = ';') 72 | # 1599x12 DataFrame 73 | # | Row | fixed_acidity | volatile_acidity | citric_acid | residual_sugar | 74 | # |------|---------------|------------------|-------------|----------------| 75 | # | 1 | 7.4 | 0.7 | 0.0 | 1.9 | 76 | # | 2 | 7.8 | 0.88 | 0.0 | 2.6 | 77 | # | 3 | 7.8 | 0.76 | 0.04 | 2.3 | 78 | # ⋮ 79 | # | 1596 | 5.9 | 0.55 | 0.1 | 2.2 | 80 | # | 1597 | 6.3 | 0.51 | 0.13 | 2.3 | 81 | # | 1598 | 5.9 | 0.645 | 0.12 | 2.0 | 82 | # | 1599 | 6.0 | 0.31 | 0.47 | 3.6 | 83 | 84 | # | Row | chlorides | free_sulfur_dioxide | total_sulfur_dioxide | density | 85 | # |------|-----------|---------------------|----------------------|---------| 86 | # | 1 | 0.076 | 11.0 | 34.0 | 0.9978 | 87 | # | 2 | 0.098 | 25.0 | 67.0 | 0.9968 | 88 | # | 3 | 0.092 | 15.0 | 54.0 | 0.997 | 89 | # ⋮ 90 | # | 1596 | 0.062 | 39.0 | 51.0 | 0.99512 | 91 | # | 1597 | 0.076 | 29.0 | 40.0 | 0.99574 | 92 | # | 1598 | 0.075 | 32.0 | 44.0 | 0.99547 | 93 | # | 1599 | 0.067 | 18.0 | 42.0 | 0.99549 | 94 | 95 | # | Row | pH | sulphates | alcohol | quality | 96 | # |------|------|-----------|---------|---------| 97 | # | 1 | 3.51 | 0.56 | 9.4 | 5 | 98 | # | 2 | 3.2 | 0.68 | 9.8 | 5 | 99 | # | 3 | 3.26 | 0.65 | 9.8 | 5 | 100 | # ⋮ 101 | # | 1596 | 3.52 | 0.76 | 11.2 | 6 | 102 | # | 1597 | 3.42 | 0.75 | 11.0 | 6 | 103 | # | 1598 | 3.57 | 0.71 | 10.2 | 5 | 104 | # | 1599 | 3.39 | 0.66 | 11.0 | 6 | 105 | typeof(data) # DataFrame 106 | size(data) # (1599,12) 107 | data[:density] 108 | # 1599-element DataArray{Float64,1}: 109 | # 0.9978 110 | # 0.9968 111 | # 0.997 112 | # 0.998 113 | # ⋮ 114 | # 0.99512 115 | # 0.99574 116 | # 0.99547 117 | # 0.99549 118 | CSV.write("dataframe1.csv", df, delim = ';') 119 | 120 | # queries: 121 | # the quality for all wines: 122 | data[:quality] 123 | # give the wines with alcohol % = 9.5 124 | show(data[ data[:alcohol].== 9.5, :]) 125 | # count the number of wines grouped by quality 126 | show(by(data, :quality, data -> size(data, 1))) 127 | # 6x2 DataFrame 128 | # | Row | quality | x1 | 129 | # |-----|---------|-----| 130 | # | 1 | 3 | 10 | 131 | # | 2 | 4 | 53 | 132 | # | 3 | 5 | 681 | 133 | # | 4 | 6 | 638 | 134 | # | 5 | 7 | 199 | 135 | # | 6 | 8 | 18 | 136 | _, count = hist(data[:quality]) 137 | #> count 6-element Array{Int64,1}: 10 53 681 638 199 18 138 | class = sort(unique(data[:quality])) 139 | #> 6-element DataArray{Int64,1}: 3 4 5 6 7 8 140 | df_quality = DataFrame(qual=class, no=count) 141 | # 6x2 DataFrame 142 | # | Row | qual | no | 143 | # |-----|------|-----| 144 | # | 1 | 3 | 10 | 145 | # | 2 | 4 | 53 | 146 | # | 3 | 5 | 681 | 147 | # | 4 | 6 | 638 | 148 | # | 5 | 7 | 199 | 149 | # | 6 | 8 | 18 | 150 | -------------------------------------------------------------------------------- /Chapter08/defs.jl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-1.0-Programming-Second-Edition/0c2aae68db4b40a919f9d3d604b1df73a1bf85b2/Chapter08/defs.jl -------------------------------------------------------------------------------- /Chapter08/echoserver.jl: -------------------------------------------------------------------------------- 1 | # start the netcat (nc) tool at the prompt to make a connection with the Julia server on port 8080: 2 | # nc localhost 8080 3 | using Sockets 4 | server = Sockets.listen(8080) 5 | while true 6 | conn = accept(server) 7 | @async begin 8 | try 9 | while true 10 | line = readline(conn) 11 | println(line) 12 | write(conn,line) 13 | end 14 | catch ex 15 | print("connection ended with error $ex") 16 | end 17 | end # end coroutine block 18 | end -------------------------------------------------------------------------------- /Chapter08/example.dat: -------------------------------------------------------------------------------- 1 | this is line 1. 2 | 42; 3.14 3 | this is line 3. -------------------------------------------------------------------------------- /Chapter08/example2.dat: -------------------------------------------------------------------------------- 1 | I write myself to a file 2 | even with println! 3 | -------------------------------------------------------------------------------- /Chapter08/functions.jl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-1.0-Programming-Second-Edition/0c2aae68db4b40a919f9d3d604b1df73a1bf85b2/Chapter08/functions.jl -------------------------------------------------------------------------------- /Chapter08/instpubs.sql: -------------------------------------------------------------------------------- 1 | /* */ 2 | /* InstPubs.SQL - Creates the Pubs database */ 3 | /* */ 4 | CREATE DATABASE pubs 5 | GO 6 | 7 | USE pubs 8 | GO 9 | 10 | CREATE TABLE titles 11 | ( 12 | title_id tid 13 | 14 | CONSTRAINT UPKCL_titleidind PRIMARY KEY CLUSTERED, 15 | 16 | title varchar(80) NOT NULL, 17 | type char(12) NOT NULL 18 | 19 | DEFAULT ('UNDECIDED'), 20 | 21 | pub_id char(4) NULL 22 | price money NULL, 23 | advance money NULL, 24 | royalty int NULL, 25 | ytd_sales int NULL, 26 | notes varchar(200) NULL, 27 | 28 | pubdate datetime NOT NULL 29 | 30 | DEFAULT (getdate()) 31 | ) 32 | GO 33 | 34 | 35 | insert titles values ('PC8888', 'Secrets of Silicon Valley', 'popular_comp', '1389', 36 | $20.00, $8000.00, 10, 4095, 37 | 'Muckraking reporting on the world''s largest computer hardware and software manufacturers.', 38 | '06/12/94') 39 | 40 | insert titles values ('BU1032', 'The Busy Executive''s Database Guide', 'business', 41 | '1389', $19.99, $5000.00, 10, 4095, 42 | 'An overview of available database systems with emphasis on common business applications. Illustrated.', 43 | '06/12/91') 44 | 45 | insert titles values ('PS7777', 'Emotional Security: A New Algorithm', 'psychology', 46 | '0736', $7.99, $4000.00, 10, 3336, 47 | 'Protecting yourself and your loved ones from undue emotional stress in the modern world. Use of computer and nutritional aids emphasized.', 48 | '06/12/91') 49 | 50 | insert titles values ('PS3333', 'Prolonged Data Deprivation: Four Case Studies', 51 | 'psychology', '0736', $19.99, $2000.00, 10, 4072, 52 | 'What happens when the data runs dry? Searching evaluations of information-shortage effects.', 53 | '06/12/91') 54 | 55 | insert titles values ('BU1111', 'Cooking with Computers: Surreptitious Balance Sheets', 56 | 'business', '1389', $11.95, $5000.00, 10, 3876, 57 | 'Helpful hints on how to use your electronic resources to the best advantage.', 58 | '06/09/91') 59 | 60 | insert titles values ('MC2222', 'Silicon Valley Gastronomic Treats', 'mod_cook', '0877', 61 | $19.99, $0.00, 12, 2032, 62 | 'Favorite recipes for quick, easy, and elegant meals.', 63 | '06/09/91') 64 | 65 | insert titles values ('TC7777', 'Sushi, Anyone?', 'trad_cook', '0877', $14.99, $8000.00, 66 | 10, 4095, 67 | 'Detailed instructions on how to make authentic Japanese sushi in your spare time.', 68 | '06/12/91') 69 | 70 | insert titles values ('TC4203', 'Fifty Years in Buckingham Palace Kitchens', 'trad_cook', 71 | '0877', $11.95, $4000.00, 14, 15096, 72 | 'More anecdotes from the Queen''s favorite cook describing life among English royalty. Recipes, techniques, tender vignettes.', 73 | '06/12/91') 74 | 75 | insert titles values ('PC1035', 'But Is It User Friendly?', 'popular_comp', '1389', 76 | $22.95, $7000.00, 16, 8780, 77 | 'A survey of software for the naive user, focusing on the ''friendliness'' of each.', 78 | '06/30/91') 79 | 80 | insert titles values('BU2075', 'You Can Combat Computer Stress!', 'business', '0736', 81 | $2.99, $10125.00, 24, 18722, 82 | 'The latest medical and psychological techniques for living with the electronic office. Easy-to-understand explanations.', 83 | '06/30/91') 84 | 85 | insert titles values('PS2091', 'Is Anger the Enemy?', 'psychology', '0736', $10.95, 86 | $2275.00, 12, 2045, 87 | 'Carefully researched study of the effects of strong emotions on the body. Metabolic charts included.', 88 | '06/15/91') 89 | 90 | insert titles values('PS2106', 'Life Without Fear', 'psychology', '0736', $7.00, $6000.00, 91 | 10, 111, 92 | 'New exercise, meditation, and nutritional techniques that can reduce the shock of daily interactions. Popular audience. Sample menus included, exercise video available separately.', 93 | '10/05/91') 94 | 95 | insert titles values('MC3021', 'The Gourmet Microwave', 'mod_cook', '0877', $2.99, 96 | $15000.00, 24, 22246, 97 | 'Traditional French gourmet recipes adapted for modern microwave cooking.', 98 | '06/18/91') 99 | 100 | insert titles values('TC3218', 'Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean', 101 | 'trad_cook', '0877', $20.95, $7000.00, 10, 375, 102 | 'Profusely illustrated in color, this makes a wonderful gift book for a cuisine-oriented friend.', 103 | '10/21/91') 104 | 105 | insert titles (title_id, title, pub_id) values('MC3026', 106 | 'The Psychology of Computer Cooking', '0877') 107 | 108 | insert titles values ('BU7832', 'Straight Talk About Computers', 'business', '1389', 109 | $19.99, $5000.00, 10, 4095, 110 | 'Annotated analysis of what computers can do for you: a no-hype guide for the critical user.', 111 | '06/22/91') 112 | 113 | insert titles values('PS1372', 'Computer Phobic AND Non-Phobic Individuals: Behavior Variations', 114 | 'psychology', '0877', $21.59, $7000.00, 10, 375, 115 | 'A must for the specialist, this book examines the difference between those who hate and fear computers and those who don''t.', 116 | '10/21/91') 117 | 118 | insert titles (title_id, title, type, pub_id, notes) values('PC9999', 'Net Etiquette', 119 | 'popular_comp', '1389', 'A must-read for computer conferencing.') 120 | 121 | GO 122 | 123 | -------------------------------------------------------------------------------- /Chapter08/io.jl: -------------------------------------------------------------------------------- 1 | # this script does not run as a whole 2 | # (the code snippets are for demo-purposes only, 3 | # and should be used on their own, and/or in the REPL 4 | # on Julia prompt: 5 | # julia> stdin 6 | # Base.TTY(Base.Libc.WindowsRawSocket(0x000000000000027c) open, 0 bytes waiting) 7 | # julia> stdout 8 | # Base.TTY(Base.Libc.WindowsRawSocket(0x0000000000000280) open, 0 bytes waiting) 9 | 10 | # read(stdin, Char) 11 | write(stdout, "Julia") #> Julia5 12 | # read(stdin,3) 13 | # readline(stdin) 14 | # input: # Julia 15 | # output: # "Julia\r\n" (Windows) - "Julia\n" (Linux) 16 | 17 | # stream can be stdin or any other input stream: 18 | stream = stdin 19 | for line in eachline(stream) 20 | println("Found $line") 21 | end 22 | 23 | while !eof(stream) 24 | x = read(stream, Char) 25 | println("Found: $x") 26 | end 27 | 28 | 29 | function process(item) 30 | # do the processing 31 | end 32 | 33 | # files: 34 | fieldnames(IOStream) 35 | #> (:handle, :ios, :name, :mark) 36 | 37 | IOStream.types 38 | #> svec(Ptr{Nothing}, Array{UInt8,1}, AbstractString, Int64) 39 | 40 | # reading: 41 | fname = "example.dat" 42 | f1 = open(fname) 43 | # IOStream() 44 | 45 | data = readlines(f1) 46 | # 3-element Array{String,1}: 47 | # "this is line 1." 48 | # "42; 3.14" 49 | # "this is line 3." 50 | 51 | for line in data 52 | println(line) 53 | process(line) 54 | end 55 | close(f1) 56 | 57 | open(fname) do file 58 | process(file) 59 | end 60 | 61 | open(fname) do file 62 | for line in eachline(file) 63 | print(line) 64 | process(line) 65 | end 66 | end 67 | 68 | # writing: 69 | fname = "example2.dat" 70 | f2 = open(fname, "w") 71 | write(f2, "I write myself to a file\n") #> 24 72 | println(f2, "even with println!") 73 | close(f2) 74 | 75 | # looping over all files in a folder: 76 | for file in readdir() 77 | process(file) 78 | end 79 | 80 | # example: 81 | mydir = pwd(); 82 | cd("..") 83 | 84 | for fn in readdir() 85 | println(fn) 86 | end 87 | # possible output: 88 | # .DS_Store 89 | # .git 90 | # Chapter 1 91 | # Chapter 2 92 | # Chapter 3 93 | # Chapter 4 94 | # Chapter 5 95 | # Chapter 6 96 | # Chapter 7 97 | # Chapter 8 98 | # Chapter 9 99 | # LICENSE 100 | # README.md 101 | 102 | cd(mydir) 103 | -------------------------------------------------------------------------------- /Chapter08/odbc.jl: -------------------------------------------------------------------------------- 1 | using ODBC, Dates 2 | ODBC.DSN("pubsODBC", ,) 3 | # Connection Data Source: pubsODBC 4 | # pubsODBC Connection Number: 1 5 | # Contains resultset? No 6 | results = ODBC.query(dsn, "select * from titles") 7 | # elapsed time: 0.189238158 seconds 8 | # 18x10 DataFrame 9 | # | Row | title_id | 10 | # |-----|----------| 11 | # | 1 | "BU1032" | 12 | # | 2 | "BU1111" | 13 | # | 3 | "BU2075" | 14 | # | 4 | "BU7832" | 15 | # | 5 | "MC2222" | 16 | # | 6 | "MC3021" | 17 | # ⋮ 18 | # | 12 | "PS2091" | 19 | # | 13 | "PS2106" | 20 | # | 14 | "PS3333" | 21 | # | 15 | "PS7777" | 22 | # | 16 | "TC3218" | 23 | # | 17 | "TC4203" | 24 | # | 18 | "TC7777" | 25 | 26 | # | Row | title | 27 | # |-----|-------------------------------------------------------------------| 28 | # | 1 | "The Busy Executive's Database Guide" | 29 | # | 2 | "Cooking with Computers: Surreptitious Balance Sheets" | 30 | # | 3 | "You Can Combat Computer Stress!" | 31 | # | 4 | "Straight Talk About Computers" | 32 | # | 5 | "Silicon Valley Gastronomic Treats" | 33 | # | 6 | "The Gourmet Microwave" | 34 | # ⋮ 35 | # Row | _type | pub_id | price | advance | royalty | ytd_sales | 36 | # -----|----------------|--------|-------|---------|---------|-----------| 37 | # 1 | "business " | "1389" | 19.99 | 5000.0 | 10 | 4095 | 38 | # 2 | "business " | "1389" | 11.95 | 5000.0 | 10 | 3876 | 39 | # 3 | "business " | "0736" | 2.99 | 10125.0 | 24 | 18722 | 40 | # 4 | "business " | "1389" | 19.99 | 5000.0 | 10 | 4095 | 41 | # 5 | "mod_cook " | "0877" | 19.99 | 0.0 | 12 | 2032 | 42 | # 6 | "mod_cook " | "0877" | 2.99 | 15000.0 | 24 | 22246 | 43 | # fname = "books.dat" 44 | # ODBC.query(dsn, "select * from titles", file=fname, delim = '\t') 45 | 46 | # updates: 47 | updsql = "update titles set type = 'psychology' where title_id='BU1032'" 48 | stmt = ODBC.prepare(dsn, updsql) 49 | ODBC.execute!(stmt) 50 | 51 | ODBC.listdrivers() 52 | ODBC.listdsns() -------------------------------------------------------------------------------- /Chapter08/parallel.jl: -------------------------------------------------------------------------------- 1 | using Distributed 2 | # start the following on the command line: 3 | # julia -p n # starts n processes on the local machine 4 | # julia -p 8 # starts REPL with 8 workers 5 | workers() 6 | # 8-element Array{Int64,1}: 7 | # 2 8 | # 3 9 | # 4 10 | # 5 11 | # ⋮ 12 | # 8 13 | # 9 14 | 15 | # iterate over workers: 16 | for pid in workers() 17 | # do something with pid 18 | end 19 | myid() # 1 20 | addprocs(5) 21 | # 5-element Array{Any,1}: 22 | # 10 23 | # 11 24 | # 12 25 | # 13 26 | # 14 27 | nprocs() # 14 28 | rmprocs(3) #> Task (done) @0x0000000012f8f0f0 29 | # worker with id 3 is removed 30 | 31 | # cluster of computers: 32 | # julia --machinefile machines driver.jl 33 | # Run processes specified in driver.jl on hosts listed in machines 34 | 35 | # primitive operations with processes: 36 | r1 = remotecall(x -> x^2, 2, 1000) #> Future(2, 1, 15, nothing) 37 | fetch(r1) #> 1000000 38 | 39 | remotecall_fetch(sin, 5, 2pi) # -2.4492935982947064e-16 40 | 41 | r2 = @spawnat 4 sqrt(2) #> Future(4, 1, 18, nothing) 42 | # lets worker 4 calculate sqrt(2) 43 | fetch(r2) #> 1.4142135623730951 44 | r = [@spawnat w sqrt(5) for w in workers()] 45 | # or in a freshly started REPL: 46 | # r = [@spawnat i sqrt(5) for i=1:length(workers())] 47 | # 12-element Array{Future,1}: 48 | # Future(2, 1, 20, nothing) 49 | # Future(4, 1, 21, nothing) 50 | # Future(5, 1, 22, nothing) 51 | # Future(6, 1, 23, nothing) 52 | # Future(7, 1, 24, nothing) 53 | # Future(8, 1, 25, nothing) 54 | # Future(9, 1, 26, nothing) 55 | # Future(10, 1, 27, nothing) 56 | # Future(11, 1, 28, nothing) 57 | # Future(12, 1, 29, nothing) 58 | # Future(13, 1, 30, nothing) 59 | # Future(14, 1, 31, nothing) 60 | r3 = @spawn sqrt(5) #> Future(2, 1, 32, nothing) 61 | fetch(r3) #> 2.23606797749979 62 | 63 | # using @everywhere to make functions available to all workers: 64 | @everywhere w = 8 65 | @everywhere println(myid()) 66 | # 1 67 | # From worker 14: 14 68 | # From worker 8: 8 69 | # From worker 10: 10 70 | # From worker 7: 7 71 | # From worker 2: 2 72 | # From worker 4: 4 73 | # From worker 12: 12 74 | # From worker 9: 9 75 | # From worker 11: 11 76 | # From worker 6: 6 77 | # From worker 13: 13 78 | # From worker 5: 5 79 | 80 | x = 5 #> 5 81 | @everywhere println(x) #> 5 82 | # # exception on worker 2: ERROR: UndefVarError: x not defined ... 83 | # ...and 11 more exception(s) 84 | 85 | @everywhere include("defs.jl") 86 | @everywhere function fib(n) 87 | if (n < 2) 88 | return n 89 | else 90 | return fib(n-1) + fib(n-2) 91 | end 92 | end 93 | 94 | r2 = @spawnat 2 fib(10) 95 | # Future(2, 1, 70, nothing) 96 | fetch(r2) 97 | # 55 98 | 99 | include("functions.jl") 100 | 101 | # broadcast data to all workers: 102 | d = "Julia" 103 | for pid in workers() 104 | remotecall(x -> (global d; d = x; nothing), pid, d) 105 | end -------------------------------------------------------------------------------- /Chapter08/parallel_loops_maps.jl: -------------------------------------------------------------------------------- 1 | using Distributed 2 | # parallel loops: 3 | function buffon(n) 4 | hit = 0 5 | for i = 1:n 6 | mp = rand() 7 | phi = (rand() * pi) - pi / 2 # angle at which needle falls 8 | xright = mp + cos(phi)/2 # x-location of needle 9 | xleft = mp - cos(phi)/2 10 | # if xright >= 1 || xleft <= 0 11 | # hit += 1 12 | # end 13 | # Does needle cross either x == 0 or x == 1? 14 | p = (xright >= 1 || xleft <= 0) ? 1 : 0 15 | hit += p 16 | end 17 | miss = n - hit 18 | piapprox = n / hit * 2 19 | end 20 | 21 | @time buffon(100000) 22 | # 0.208500 seconds (504.79 k allocations: 25.730 MiB, 7.10% gc time) 23 | # 3.1441597233139444 24 | @time buffon(100000000) 25 | # 4.112683 seconds (5 allocations: 176 bytes) 26 | # 3.141258861373451 27 | 28 | function buffon_par(n) 29 | hit = @distributed (+) for i = 1:n 30 | mp = rand() 31 | phi = (rand() * pi) - pi / 2 32 | xright = mp + cos(phi)/2 33 | xleft = mp - cos(phi)/2 34 | (xright >= 1 || xleft <= 0) ? 1 : 0 35 | end 36 | miss = n - hit 37 | piapprox = n / hit * 2 38 | end 39 | @time buffon_par(100000) 40 | # 1.058487 seconds (951.35 k allocations: 48.192 MiB, 2.04% gc time) 41 | # 3.15059861373661 42 | 43 | @time buffon_par(100000000) 44 | # 0.735853 seconds (1.84 k allocations: 133.156 KiB) 45 | # 3.1418106012575633 46 | 47 | # arr is not correctly initialized: 48 | arr = zeros(100000) 49 | @distributed for i=1:100000 50 | arr[i] = i 51 | end #> Task (queued) @0x00000000147ad430 52 | #> arr only contains zeros! 53 | 54 | # parallel maps: 55 | using LinearAlgebra 56 | function rank_marray() 57 | marr = [rand(1000,1000) for i=1:10] 58 | for arr in marr 59 | println(rank(arr)) 60 | end 61 | end 62 | 63 | @time rank_marray() 64 | # 1000 65 | # 1000 66 | # 1000 67 | # 1000 68 | # 1000 69 | # 1000 70 | # 1000 71 | # 1000 72 | # 1000 73 | # 1000 74 | # 7.310404 seconds (91.33 k allocations: 162.878 MiB, 1.15% gc time) 75 | 76 | function prank_marray() 77 | marr = [rand(1000,1000) for i=1:10] 78 | println(pmap(rank, marr)) 79 | end 80 | @time prank_marray() 81 | # {1000,1000,1000,1000,1000,1000,1000,1000,1000,1000} 82 | # 5.966216 seconds (4.15 M allocations: 285.610 MiB, 2.15% gc time) -------------------------------------------------------------------------------- /Chapter08/partial.dat: -------------------------------------------------------------------------------- 1 | citric acid;free sulfur dioxide;alcohol 2 | 0;11;9.4 3 | 0;25;9.8 4 | 0.04;15;9.8 5 | 0.56;17;9.8 6 | 0;11;9.4 7 | 0;13;9.4 8 | 0.06;15;9.4 9 | 0;15;10 10 | 0.02;9;9.5 11 | 0.36;17;10.5 12 | 0.08;15;9.2 13 | 0.36;17;10.5 14 | 0;16;9.9 15 | 0.29;9;9.1 16 | 0.18;52;9.2 17 | 0.19;51;9.2 18 | 0.56;35;10.5 19 | 0.28;16;9.3 20 | 0.08;6;9 21 | 0.51;17;9.2 22 | 0.48;29;9.4 23 | 0.31;23;9.7 24 | 0.21;10;9.5 25 | 0.11;9;9.4 26 | 0.14;21;9.7 27 | 0.16;11;9.3 28 | 0.24;4;9.5 29 | 0.21;10;9.5 30 | 0;14;9.4 31 | 0;8;9.8 32 | 0.07;17;10.1 33 | 0;22;10.6 34 | 0.12;15;9.8 35 | 0.12;40;9.4 36 | 0.25;13;9.2 37 | 0;5;9.6 38 | 0.14;3;10.8 39 | 0.28;13;9.7 40 | 0.09;7;9.8 41 | 0.36;12;10.5 42 | 0.36;12;10.5 43 | 0.3;17;9.3 44 | 0.2;8;10.5 45 | 0.22;9;10.3 46 | 0.02;5;9.5 47 | 0.15;8;13.1 48 | 0.43;22;9.2 49 | 0.52;12;9.5 50 | 0.23;5;9.2 51 | 0.37;12;9.2 52 | 0.26;4;9.2 53 | 0.04;8;9.4 54 | 0.04;6;9.4 55 | 0.36;30;9.4 56 | 0.15;33;10.2 57 | 0.04;25;9.5 58 | 0.57;4;9.6 59 | 0.12;50;9.4 60 | 0.18;17;10 61 | 0.31;9;9.4 62 | 0.4;19;9.2 63 | 0.49;20;9.3 64 | 0.16;12;9.5 65 | 0.05;13;9.8 66 | 0.05;4;10.9 67 | 0.05;4;10.9 68 | 0.11;11;9.6 69 | 0.07;6;10.7 70 | 0.57;27;10.7 71 | 0.05;8;10.5 72 | 0.08;15;9.5 73 | 0.23;17;9.5 74 | 0.22;18;9.5 75 | 0.26;11;9.2 76 | 0.54;28;9.6 77 | 0.64;9;10.5 78 | 0.64;9;10.5 79 | 0;14;10.7 80 | 0.12;12;10.1 81 | 0.2;27;9.1 82 | 0.2;3;9.2 83 | 0.7;22;9.4 84 | 0.47;21;9.1 85 | 0.26;16;9.4 86 | 0.48;18;10.3 87 | 0.15;19;10.1 88 | 0.28;20;9.9 89 | 0.26;9;9.6 90 | 0.44;34;9.5 91 | 0.08;8;9 92 | 0.26;42;9.5 93 | 0.28;20;9.9 94 | 0.29;19;9.8 95 | 0.26;9;9.6 96 | 0.04;41;10.5 97 | 0.17;17;12.9 98 | 0;8;10.7 99 | 0.25;3;9.2 100 | 0.06;5;9.8 101 | 0.18;13;9 102 | 0.3;11;10.2 103 | 0.3;8;10.4 104 | 0.18;13;9 105 | 0.22;12;9.2 106 | 0.24;5;9.4 107 | 0.22;12;9.2 108 | 0.68;18;9.3 109 | 0.31;15;9.3 110 | 0.53;18;9.6 111 | 0.52;37;9.3 112 | 0.19;12;9.5 113 | 0.09;11;9.8 114 | 0.1;14;9.8 115 | 0.44;22;9.7 116 | 0.19;12;9.5 117 | 0.31;13;10.5 118 | 0.28;11;10 119 | 0.12;7;9.4 120 | 0.04;14;10.9 121 | 0.08;22;9.2 122 | 0.09;10;9 123 | 0.04;14;10.9 124 | 0;3;9.2 125 | 0;11;9.5 126 | 0.17;21;9.5 127 | 0.04;27;9.4 128 | 0;3;10.9 129 | 0;3;10.9 130 | 0.16;3;10.5 131 | 0.15;6;9.4 132 | 0.56;30;9.4 133 | 0.09;17;13 134 | 0.09;17;13 135 | 0.01;17;9.8 136 | 0.05;13;9.9 137 | 0.11;16;9.6 138 | 0.15;10;9.5 139 | 0.36;13;9.2 140 | 0.19;15;9.5 141 | 0.19;17;9.5 142 | 0.11;16;9.6 143 | 0.15;10;9.5 144 | 0;27;14 145 | 0.08;3;9.4 146 | 0;27;14 147 | 0.55;32;9.4 148 | 0.02;21;10 149 | 0.26;10;9.3 150 | 0.1;12;10.2 151 | 0.44;11;10.5 152 | 0.47;5;10.3 153 | 1;32;9.4 154 | 0.03;25;10.1 155 | 0.03;25;10.1 156 | 0.42;29;10.5 157 | 0.42;28;10.5 158 | 0.42;29;10.5 159 | 0.42;28;10.5 160 | 0;12;9.3 161 | 0.18;18;9.3 162 | 0.03;7;9.6 163 | 0.02;9;9.2 164 | 0.04;17;10 165 | 0.26;36;9.4 166 | 0.26;35;9.4 167 | 0.48;14;9.5 168 | 0.1;18;10.2 169 | 0.03;17;9 170 | 0.07;11;10.4 171 | 0.24;15;9.5 172 | 0.03;4;9.1 173 | 0.17;6;9.2 174 | 0.17;6;9.2 175 | 0.05;24;11.5 176 | 0.21;7;9.5 177 | 0.04;19;9.5 178 | 0.21;7;9.5 179 | 0.42;8;10.5 180 | 0;7;9.6 181 | 0.14;10;9.5 182 | 0.14;10;9.5 183 | 0.49;23;9.3 184 | 0.02;16;9.3 185 | 0.2;11;9.3 186 | 0.21;8;9.3 187 | 0.57;26;9.7 188 | 0.48;14;9.2 189 | 0.1;9;9.7 190 | 0.33;15;9.5 191 | 0.32;17;9.5 192 | 0.35;21;9.4 193 | 0.25;21;9.8 194 | 0.12;16;9.5 195 | 0.21;7;9.7 196 | 0.21;7;9.7 197 | 0.33;24;9.4 198 | 0.3;15;10.2 199 | 0.6;12;10.1 200 | 0.08;13;13 201 | 0.06;12;11.4 202 | 0.47;9;10.3 203 | 0.48;39;9.3 204 | 0.11;16;9.5 205 | 0.35;16;9.2 206 | 0.36;14;9.2 207 | 0.74;9;10.8 208 | 0.74;9;10.8 209 | 0.31;26;9.3 210 | 0.28;18;9.4 211 | 0.58;7;10.5 212 | 0.6;5;12.4 213 | 0.24;10;10 214 | 0.64;5;10.2 215 | 0.26;28;10.1 216 | 0.08;10;9.8 217 | 0.49;26;10.5 218 | 0.16;13;11 219 | 0.22;11;9.1 220 | 0.19;10;9.7 221 | 0.33;24;9.5 222 | 0.37;24;9.4 223 | 0.26;16;9.4 224 | 0.04;5;9.5 225 | 0.25;8;10 226 | 0.36;15;10.4 227 | 0.25;29;10.5 228 | 0.5;27;9.5 229 | 0.14;9;9.8 230 | 0.25;29;10.5 231 | 0.25;10;11 232 | 0.04;19;12.2 233 | 0.06;12;9.9 234 | 0.2;18;9.6 235 | 0.25;10;11 236 | 0.09;7;9 237 | 0;14;9 238 | 0;14;9 239 | 0;15;9.2 240 | 0;14;9 241 | 0.09;7;9 242 | 0.37;5;9.3 243 | 0.56;6;10.9 244 | 0.1;28;9.8 245 | 0.44;10;9.2 246 | 0.44;10;9.2 247 | 0;6;9.9 248 | 0.07;16;9.5 249 | 0.17;11;9.3 250 | 0.06;9;9.8 251 | 0;6;9.9 252 | 0.44;16;10 253 | 0;16;9.9 254 | 0.48;5;10.5 255 | 0.42;8;9.5 256 | 0;16;9.9 257 | 0.23;17;9.3 258 | 0.37;5;9.2 259 | 0;12;9.2 260 | 0.76;8;9.4 261 | 0.47;14;10.5 262 | 0.23;18;9.3 263 | 0.04;12;9.4 264 | 0.03;10;10 265 | 0.23;23;9.3 266 | 0.49;5;10.9 267 | 0.52;6;10.2 268 | 0;26;9.8 269 | 0.46;15;12.8 270 | 0.04;7;9.4 271 | 0.51;4;10.1 272 | 0.06;27;10.7 273 | 0.51;4;10.1 274 | 0.58;17;10.1 275 | 0.2;10;9.4 276 | 0.18;27;9.4 277 | 0.06;27;10.7 278 | 0.04;7;9.4 279 | 0.51;4;10.1 280 | 0.45;5;12.6 281 | 0.32;10;10.5 282 | 0.44;6;9.3 283 | 0.68;5;9.9 284 | 0.12;12;9.1 285 | 0.32;10;10.5 286 | 0.07;32;9.8 287 | 0.07;32;9.8 288 | 0.55;25;10.3 289 | 0.12;29;10.3 290 | 0.09;20;10.6 291 | 0.53;33;9.2 292 | 0.09;20;10.6 293 | 0.48;6;10.5 294 | 0.23;18;10.3 295 | 0.25;5;10.1 296 | 0.52;17;9.5 297 | 0.46;5;9.5 298 | 0.37;26;9.9 299 | 0.06;8;9.6 300 | 0.02;5;9.7 301 | 0.06;8;9.6 302 | 0.06;20;10.7 303 | 0.48;7;10.1 304 | 0.12;12;10 305 | 0.12;5;9.5 306 | 0.6;12;9.2 307 | 0.48;6;9.3 308 | 0.32;7;9.4 309 | 0.42;6;9.5 310 | 0.44;5;9.5 311 | 0.38;9;9.5 312 | 0.48;6;9.3 313 | 0.24;15;9.4 314 | 0.31;19;9.5 315 | 0.3;30;9.4 316 | 0.29;26;11 317 | 0.29;20;11 318 | 0.23;37;10.1 319 | 0.12;30;10.4 320 | 0.39;21;11.5 321 | 0.12;30;10.4 322 | 0.39;21;11.5 323 | 0.26;25;9.7 324 | 0.05;6;9.3 325 | 0.42;35;9.5 326 | 0.2;13;9.2 327 | 0.2;13;9.2 328 | 0.66;6;11.5 329 | 0.5;5;11.5 330 | 0.62;6;9.7 331 | 0.39;7;9.5 332 | 0.64;10;12.5 333 | 0.64;10;12.5 334 | 0.28;21;9.4 335 | 0.08;16;11 336 | 0.01;17;11.7 337 | 0.53;7;12.2 338 | 0.45;6;12.5 339 | 0.32;29;10.3 340 | 0.58;28;11.5 341 | 0.54;12;9.8 342 | 0.5;10;9.2 343 | 0.48;5;11.3 344 | 0.47;6;9.8 345 | 0.47;6;9.8 346 | 0.5;6;10.7 347 | 0;40;9.9 348 | 0.02;17;12.3 349 | 0.67;6;12 350 | 0.31;15;10 351 | 0;11;9.4 352 | 0.22;17;9.9 353 | 0;11;9.4 354 | 0;8;9.3 355 | 0.79;23;13 356 | 0.4;40.5;11.9 357 | 0.01;17;12.8 358 | 0.52;29;11 359 | 0.66;12;11.7 360 | 0.66;10;10.4 361 | 0.66;10;9.8 362 | 0.23;14;9.4 363 | 0.31;21;9.9 364 | 0.66;6;10 365 | 0.63;6;10.2 366 | 0.66;7;10 367 | 0.5;7;11.8 368 | 0.66;7;10 369 | 0.61;11;9 370 | 0.52;15;9.4 371 | 0.53;6;12 372 | 0.02;35;9.9 373 | 0.4;11;8.7 374 | 0.48;26;10.6 375 | 0.22;12;9.2 376 | 0.63;6;10.8 377 | 0.71;6;11.8 378 | 0.5;19;11 379 | 0.53;6;12 380 | 0.66;6;13.3 381 | 0.38;24;10.8 382 | 0.42;11;9.4 383 | 0.68;17;10 384 | 0.42;11;9.4 385 | 0.42;11;9.4 386 | 0.28;23;9.2 387 | 0.07;11;9.7 388 | 0.26;23;9.2 389 | 0.15;17;9.6 390 | 0.26;23;9.2 391 | 0.31;16;10 392 | 0.05;12;12.9 393 | 0.68;17;10 394 | 0.52;6;9.5 395 | 0.61;13;9.1 396 | 0.65;6;9.9 397 | 0.76;7;13 398 | 0.02;68;9.9 399 | 0.59;13;11 400 | 0.59;13;11 401 | 0.22;9;9.4 402 | 0.02;68;9.9 403 | 0.3;20;10.8 404 | 0.54;19;10.5 405 | 0.49;10;10.5 406 | 0.05;15;9.1 407 | 0.46;11;10.1 408 | 0.47;9;10.8 409 | 0.66;12;10.8 410 | 0.58;6;11.3 411 | 0.49;26;9.6 412 | 0.34;26;9.5 413 | 0.35;23;9.5 414 | 0.16;15;9.3 415 | 0.53;6;11.7 416 | 0.34;24;9.5 417 | 0.24;31;9.3 418 | 0.64;6;11.7 419 | 0.12;34;10.5 420 | 0.51;7;10.4 421 | 0;34;9.9 422 | 0.33;35;11.8 423 | 0.03;32;12.3 424 | 0.2;15;10.9 425 | 0.47;6;11 426 | 0.2;15;10.9 427 | 0.03;32;12.3 428 | 0.08;19;11.4 429 | 0.22;6;10.6 430 | 0.33;9;9.3 431 | 0.63;13;10.4 432 | 0.47;6;11 433 | 0.35;21;9.2 434 | 0.69;12;12.8 435 | 0.63;6;9.5 436 | 0.55;22;9.9 437 | 0.63;6;9.5 438 | 0.3;38;10.2 439 | 0.73;6;11.2 440 | 0.55;22;9.9 441 | 0.18;7;9.3 442 | 0.72;6;9.8 443 | 0.65;7;11.3 444 | 0.76;6;11.2 445 | 0.49;11;11.6 446 | 0.01;5;12.5 447 | 0.1;6;10.1 448 | 0.6;31;10.5 449 | 0.29;6;11.2 450 | 0.22;7;10.2 451 | 0.69;17;10.8 452 | 0.69;17;10.8 453 | 0.53;9;9.1 454 | 0.03;18;10 455 | 0.63;5;11.2 456 | 0.4;21;11.1 457 | 0.67;6;13.4 458 | 0.39;5;10.3 459 | 0.21;29;9.6 460 | 0.63;5;11.2 461 | 0.66;10;9 462 | 0.52;14;11.3 463 | 0.22;6;9.3 464 | 0.68;10;11.8 465 | 0.7;25;9 466 | 0.54;5;9.2 467 | 0.4;10;9.7 468 | 0.42;21;11.5 469 | 0.45;7;14 470 | 0.69;6;9.2 471 | 0.02;36;9.8 472 | 0.65;15;10.6 473 | 0.42;25;11.4 474 | 0.55;25;10.4 475 | 0.55;5;10.6 476 | 0.51;10;9.4 477 | 0.24;5;10.2 478 | 0.41;6;9.7 479 | 0.49;6;11 480 | 0.24;5;10.2 481 | 0.11;6;10.1 482 | 0.39;6;9.2 483 | 0.56;6;11.7 484 | 0.59;6;9.4 485 | 0.6;7;9.4 486 | 0.68;6;13.4 487 | 0.39;6;10 488 | 0.39;6;10 489 | 0.36;5;10 490 | 0.55;35;10.8 491 | 0.4;10;10.2 492 | 0.27;24;10.6 493 | 0.5;12;13.3 494 | 0.51;13;13.4 495 | 0.31;23;11.6 496 | 0.23;28;12.1 497 | 0.53;5;11 498 | 0.25;14;9 499 | 0.32;43;11.1 500 | 0.53;5;11 501 | 0.31;23;11.6 502 | 0.25;14;9 503 | 0.73;38;12 504 | 0.73;38;12 505 | 0.47;6;10.9 506 | 0.42;6;10.8 507 | 0.63;10;12.5 508 | 0.46;6;10.8 509 | 0.55;6;9.5 510 | 0.31;26;10.2 511 | 0.75;23;11.4 512 | 0.49;19;9.5 513 | 0.31;26;10.2 514 | 0.48;15;9.7 515 | 0.64;6;11.8 516 | 0.64;6;11.8 517 | 0.49;34;9.3 518 | 0.49;5;11.9 519 | 0.49;5;8.4 520 | 0.49;11;11.7 521 | 0.49;39;11 522 | 0.49;15;10 523 | 0.49;16;9.1 524 | 0.49;47;9.8 525 | 0.49;38;9.4 526 | 0.49;23;9.5 527 | 0.24;29;9.9 528 | 0.49;39;11 529 | 0.49;33;11.4 530 | 0.49;32;8.7 531 | 0.24;6;9.4 532 | 0.24;1;10.3 533 | 0.49;12;10.3 534 | 0.49;12;10.3 535 | 0.24;15;12.8 536 | 0.24;13;10 537 | 0.24;1;10.3 538 | 0.24;6;9.4 539 | 0.24;5;10.7 540 | 0.49;5;12 541 | 0.74;5;11.2 542 | 0.24;20;9.6 543 | 0.49;5;11 544 | 0.24;5;9.9 545 | 0.24;16;11 546 | 0.74;6;8.4 547 | 0.49;38;9.1 548 | 0.24;10;9.5 549 | 0.49;6;10.7 550 | 0.49;27;10.4 551 | 0.49;6;9.4 552 | 0.01;9;9.5 553 | 0.24;14;10 554 | 0.24;14;10 555 | 0.24;32;11.5 556 | 0.49;10;11.1 557 | 0.49;10;11.1 558 | 0.49;10;11.7 559 | 0.49;10;11.1 560 | 0.49;10;11.7 561 | 0.49;6;12.7 562 | 0.49;5;11.4 563 | 0.49;26;9.2 564 | 0.49;41;9.2 565 | 0.49;25;10.1 566 | 0.49;6;12.7 567 | 0.49;5;11.4 568 | 0.24;5;9 569 | 0.24;5;9 570 | 0.49;5;10.7 571 | 0.24;19;11.7 572 | 0.49;10;11 573 | 0.24;19;11.7 574 | 0.49;10;10.4 575 | 0.49;14;9.6 576 | 0.49;20;10 577 | 0.49;28;10.2 578 | 0.24;6;10 579 | 0.49;18;9.5 580 | 0.49;17;9.8 581 | 0.49;18;9.8 582 | 0.49;5;9.6 583 | 0.49;5;9.6 584 | 0.49;5;9.2 585 | 0.49;10;9.9 586 | 0.49;54;10.7 587 | 0.24;8;9.6 588 | 0.49;16;10.6 589 | 0.24;18;9.3 590 | 0.24;19;14 591 | 0.49;5;10.5 592 | 0.49;21;9.7 593 | 0.49;23;11.5 594 | 0.49;21;9.7 595 | 0.58;9;9 596 | 0.17;20;9.5 597 | 0.41;30;9.3 598 | 0.51;6;9.3 599 | 0.58;5;10 600 | 0.18;5;9.8 601 | 0.45;11;9.3 602 | 0.27;7;10 603 | 0.52;12;9 604 | 0;6;9.3 605 | 0.52;12;9 606 | 0.13;14;9.1 607 | 0.13;6;9.2 608 | 0.48;10;12.2 609 | 0.41;26;10.5 610 | 0.37;11;10.4 611 | 0.19;15;12.7 612 | 0.54;25;9.2 613 | 0.55;5;9.4 614 | 0;18;10 615 | 0.38;10;9.8 616 | 0.18;10;10.2 617 | 0.5;28;9.7 618 | 0.5;28;9.7 619 | 0.51;14;9.8 620 | 0.5;4;10.2 621 | 0.41;6;9.3 622 | 0.24;16;9.4 623 | 0.23;14;9.4 624 | 0.22;9;9.5 625 | 0.25;21;12.1 626 | 0;21;10.2 627 | 0;21;10.2 628 | 0.29;5;9.1 629 | 0.29;5;9.1 630 | 0.26;7;9.3 631 | 0.23;20;9.3 632 | 0.26;7;9.3 633 | 0.54;5;9.5 634 | 0.14;21;10.5 635 | 0.22;11;11.3 636 | 0.21;46;9.5 637 | 0;24;9.7 638 | 0.28;30;9.4 639 | 0.27;31;9.4 640 | 0.12;7;10.2 641 | 0.35;25;10.3 642 | 0.45;16;9.4 643 | 0.44;21;9.5 644 | 0.45;16;9.4 645 | 0.44;21;9.5 646 | 0.45;16;9.4 647 | 0.1;5;10.1 648 | 0.05;6;10.1 649 | 0.01;5;11 650 | 0.3;10;11.2 651 | 0.27;24;11.3 652 | 0.39;8;9.6 653 | 0.25;35;11.2 654 | 0.65;22;14.9 655 | 0.59;9;12 656 | 0.47;7;9.5 657 | 0.17;20;9.4 658 | 0.39;8;9.6 659 | 0.59;23;10.5 660 | 0.07;5;9.6 661 | 0.02;5;11 662 | 0.07;5;9.6 663 | 0.31;15;9 664 | 0.06;9;9.6 665 | 0.46;5;10.2 666 | 0.52;15;10.2 667 | 0.14;25;9.7 668 | 0.36;6;9.5 669 | 0.45;6;9.2 670 | 0.43;15;11 671 | 0.45;6;9.2 672 | 0.24;30;10 673 | 0.21;5;9.5 674 | 0.34;32;9.5 675 | 0.21;5;9.5 676 | 0.41;7;9.3 677 | 0.39;12;10.2 678 | 0.41;7;9.3 679 | 0.11;12;9.9 680 | 0.1;45;10 681 | 0.45;20;9.6 682 | 0.58;15;9 683 | 0.23;16;10.2 684 | 0.31;32;9.8 685 | 0.23;5;11.3 686 | 0.32;35;9.4 687 | 0.23;5;11.3 688 | 0.18;13;9.1 689 | 0.23;13;9.7 690 | 0.04;4;9.4 691 | 0.48;5;9.4 692 | 0;5;10.7 693 | 0.24;12;9.8 694 | 0.51;16;9 695 | 0.32;21;9.4 696 | 0.31;24;9.4 697 | 0.02;18;12.8 698 | 0.02;8;9.5 699 | 0.02;8;9.5 700 | 0.28;18;9.7 701 | 0.55;5;10.8 702 | 0.43;26;10.1 703 | 0.02;8;9.5 704 | 0.02;9;9.4 705 | 0.48;22;9.6 706 | 0.04;4;9.7 707 | 0.15;11;9.9 708 | 0.08;10;10 709 | 0.19;16;10.5 710 | 0.12;11;11.6 711 | 0.47;13;10 712 | 0.43;21;10.1 713 | 0.34;16;9.5 714 | 0;13;9.4 715 | 0.36;10;9.4 716 | 0.28;21;9.8 717 | 0.18;13;9.2 718 | 0.36;10;9.4 719 | 0.11;12;10 720 | 0.04;10;9.6 721 | 0;17;9.5 722 | 0.04;10;9.6 723 | 0.24;35;9.2 724 | 0.08;15;10 725 | 0.3;36;9.5 726 | 0.1;5;11.2 727 | 0.17;5;10.4 728 | 0.09;18;11.1 729 | 0.02;4;9.5 730 | 0.02;4;9.5 731 | 0.03;27;12.7 732 | 0.66;12;9.6 733 | 0.13;4;11.5 734 | 0.03;10;9.6 735 | 0.34;16;9.5 736 | 0.2;9;9.3 737 | 0.1;11;9.5 738 | 0.1;11;9.5 739 | 0;19;9.3 740 | 0.23;28;9.2 741 | 0;19;9.3 742 | 0.29;12;11.5 743 | 0.24;28;9.5 744 | 0;9;9.2 745 | 0.58;25;10 746 | 0.54;21;9.5 747 | 0.18;12;9.5 748 | 0.38;12;9 749 | 0.4;16;9.4 750 | 0.18;12;9.6 751 | 0.18;12;9.5 752 | 0.1;17;9.5 753 | 0.1;17;9.5 754 | 0.13;24;9.4 755 | 0.1;17;9.5 756 | 0.68;14;9.1 757 | 0.07;22;10.7 758 | 0.01;15;11.2 759 | 0;10;9.8 760 | 0;10;9.8 761 | 0.21;33;9.2 762 | 0.25;9;9.7 763 | 0.26;5;9.6 764 | 0;8;10 765 | 0.26;5;9.6 766 | 0.11;11;9.5 767 | 0.1;12;9.5 768 | 0.18;12;9.4 769 | 0.32;13;9.5 770 | 0.02;24;9.7 771 | 0.01;7;9.6 772 | 0.02;24;9.7 773 | 0.26;23;9.4 774 | 0.27;23;9.4 775 | 0.29;1;9.5 776 | 0.3;2;9.5 777 | 0;7;10 778 | 0.18;5.5;10.3 779 | 0.17;6;10.3 780 | 0.3;7;10.5 781 | 0.03;21;9.8 782 | 0;12;9.4 783 | 0.14;9;9.8 784 | 0.05;26;10 785 | 0.14;9;9.8 786 | 0.01;20;9.8 787 | 0.41;11;9.5 788 | 0.41;11;9.5 789 | 0.24;19;10.1 790 | 0.24;19;10.1 791 | 0.17;21;9.3 792 | 0.43;18;9.7 793 | 0.17;25;9.6 794 | 0.02;17;9.7 795 | 0;7;10.8 796 | 0.54;7;12.5 797 | 0.3;7;10.2 798 | 0.31;24;9.6 799 | 0.44;21;10.8 800 | 0.34;5;10.7 801 | 0.34;5;10.7 802 | 0.08;26;9.4 803 | 0.09;8;10 804 | 0;14;12.9 805 | 0.08;14;9.6 806 | 0.22;4;9.9 807 | 0.4;4;12.8 808 | 0.39;4;12.5 809 | 0.4;4;12.8 810 | 0.12;4;9.2 811 | 0.31;4;10.3 812 | 0.1;4;10.5 813 | 0.55;7;10.9 814 | 0.33;20;10.8 815 | 0.24;4;11.4 816 | 0.54;19;11.3 817 | 0.33;20;10.8 818 | 0.19;8;10.5 819 | 0.42;19;11.9 820 | 0;21;9.4 821 | 0.15;9;9.6 822 | 0;9;9.7 823 | 0;16;14 824 | 0.13;15;9.8 825 | 0.13;15;9.8 826 | 0.28;6;10.3 827 | 0.14;15;10.7 828 | 0.34;4;11 829 | 0.14;15;10.7 830 | 0.09;34;12.7 831 | 0.08;16;11.1 832 | 0.07;5;10.9 833 | 0.08;16;11.1 834 | 0.42;34;9.9 835 | 0.44;36;9.9 836 | 0.26;16;9.4 837 | 0.1;27;9.3 838 | 0.28;36;11.7 839 | 0.28;36;11.7 840 | 0.35;9;11.2 841 | 0.04;13;10 842 | 0.47;9;12.1 843 | 0;21;10.3 844 | 0.45;34;10.9 845 | 0.35;9;9.4 846 | 0.46;26;10.6 847 | 0.21;14;9.8 848 | 0.21;14;9.8 849 | 0.16;12;9.9 850 | 0.21;14;9.8 851 | 0.21;12;9.8 852 | 0.44;9;9.5 853 | 0.44;9;9.5 854 | 0.32;26;9.7 855 | 0.39;41;10.9 856 | 0.39;41;10.9 857 | 0.02;10;11.7 858 | 0.39;41;10.9 859 | 0.34;16;11.3 860 | 0.47;17;10.6 861 | 0.22;15;11.2 862 | 0.06;15;9.5 863 | 0.66;15;11.5 864 | 0.32;7;10.4 865 | 0.06;17;9.7 866 | 0.06;15;9.5 867 | 0.07;16;9.7 868 | 0.22;13;11.3 869 | 0.23;13;11.2 870 | 0.22;15;11.2 871 | 0.03;27;10.9 872 | 0.01;31;11.8 873 | 0.03;36;10.6 874 | 0.24;28;10 875 | 0.37;6;11.1 876 | 0.46;6;11.8 877 | 0.4;7;11.8 878 | 0;7;10.9 879 | 0.01;31;11.8 880 | 0.19;30;10 881 | 0.04;18;9.5 882 | 0.18;10;9.9 883 | 0;30;11.4 884 | 0.29;14;12 885 | 0.04;18;9.5 886 | 0.19;30;10 887 | 0.14;9;10.5 888 | 0.12;8;10.4 889 | 0.38;29;12.1 890 | 0;32;11.2 891 | 0.34;23;9.3 892 | 0.24;30;10.1 893 | 0.03;16;9.7 894 | 0.23;10;9.3 895 | 0.03;16;9.7 896 | 0.03;17;9.8 897 | 0.01;27;10.7 898 | 0.39;17;12.5 899 | 0.01;27;10.7 900 | 0.39;17;12.5 901 | 0.02;6;11 902 | 0.36;10;11.8 903 | 0.1;16;10.8 904 | 0.1;16;10.8 905 | 0.06;11;10.8 906 | 0.06;11;10.8 907 | 0.2;15;9.5 908 | 0.27;12;11 909 | 0;6;11.5 910 | 0.13;34;10.8 911 | 0.39;7;11.5 912 | 0.48;3;13.2 913 | 0.46;3;10.9 914 | 0.44;4;12.2 915 | 0.46;3;12.2 916 | 0.39;7;11.5 917 | 0.4;3;11.9 918 | 0.19;7;11 919 | 0.31;26;10.1 920 | 0.32;32;11 921 | 0.12;38;11.8 922 | 0.37;10;10.5 923 | 0.32;32;11 924 | 0.12;38;11.8 925 | 0.31;26;10.1 926 | 0.27;14;11.2 927 | 0.36;53;11 928 | 0.33;52;10.2 929 | 0.19;11;9.2 930 | 0.27;14;11.2 931 | 0.38;10;12 932 | 0.01;8;10.5 933 | 0.01;13;9.8 934 | 0.29;29;9.5 935 | 0.01;13;9.8 936 | 0.01;8;10.5 937 | 0.38;19;11.8 938 | 0.38;19;11.8 939 | 0.5;6;10.4 940 | 0.38;23;12.9 941 | 0.17;7;11.4 942 | 0.52;13;12.4 943 | 0.49;9;12.5 944 | 0.4;13;10 945 | 0.34;10;9.7 946 | 0.49;11;12.1 947 | 0.42;7;11.1 948 | 0.58;11;12 949 | 0.48;6;12.4 950 | 0.45;10;11.9 951 | 0.45;10;11.9 952 | 0.45;10;11.9 953 | 0.48;6;12.4 954 | 0.4;6;11.2 955 | 0.48;5;12.1 956 | 0.4;6;12.2 957 | 0.52;9;10.4 958 | 0.52;5;11.3 959 | 0.52;12;11.1 960 | 0.12;25;11.3 961 | 0.05;12;10 962 | 0.27;18;11.1 963 | 0.14;7;9.3 964 | 0.02;6;9.5 965 | 0.39;20;11.2 966 | 0.27;18;11.1 967 | 0.4;24;11 968 | 0.41;6;11.9 969 | 0.2;23;9.2 970 | 0.43;29;12.2 971 | 0.09;7;10.2 972 | 0.48;6;10.9 973 | 0.48;6;10.9 974 | 0.5;6;11.6 975 | 0.44;6;10.7 976 | 0.41;7;12.1 977 | 0.3;35;9.4 978 | 0.3;35;9.4 979 | 0.29;31;9.1 980 | 0.32;9;11.3 981 | 0.49;3;10.4 982 | 0.3;8;10.5 983 | 0.26;13;10 984 | 0.32;51;12.9 985 | 0.3;8;10.5 986 | 0.49;3;10.4 987 | 0;7;11.3 988 | 0.39;3;11.4 989 | 0.3;35;9.4 990 | 0.12;19;9.4 991 | 0.4;14;10.9 992 | 0.12;19;9.4 993 | 0.28;31;9.4 994 | 0.1;30;9.4 995 | 0.28;31;9.4 996 | 0.45;20;9.4 997 | 0.06;19;10.1 998 | 0;3;12.8 999 | 0;3;12.8 1000 | 0.34;4;9.1 1001 | 0;7;12.9 1002 | 0.3;6;11.5 1003 | 0.38;31;10.6 1004 | 0.33;13;11.7 1005 | 0.32;4;12.8 1006 | 0.29;27;10.3 1007 | 0.32;4;12.8 1008 | 0.33;13;11.7 1009 | 0.34;12;11.7 1010 | 0.4;12;12 1011 | 0.36;26;10.9 1012 | 0.45;7;12.3 1013 | 0.31;12;10.4 1014 | 0.15;11;10 1015 | 0;22;10 1016 | 0.16;3;11.2 1017 | 0.46;14;11.4 1018 | 0.4;12;12.6 1019 | 0.37;36;12.7 1020 | 0.37;36;12.7 1021 | 0.14;10;10.4 1022 | 0.66;3;11.9 1023 | 0.66;3;11.9 1024 | 0.09;4;10.5 1025 | 0.42;3;12.3 1026 | 0.01;12;10.5 1027 | 0;17;10.4 1028 | 0.32;14;12.6 1029 | 0;28;11.6 1030 | 0.21;41;10.1 1031 | 0.01;12;10.5 1032 | 0;9;11.5 1033 | 0.01;9;11 1034 | 0;5;9.6 1035 | 0.08;14;10.4 1036 | 0.18;15;9.7 1037 | 0.34;5;10.6 1038 | 0.34;26;12.5 1039 | 0.1;20;9.2 1040 | 0.41;25;12.6 1041 | 0.21;21;11.1 1042 | 0;16;10.2 1043 | 0.19;13;9.8 1044 | 0.21;21;11.1 1045 | 0.41;18;10.9 1046 | 0.33;12;12.2 1047 | 0;32;11.4 1048 | 0;33;10.7 1049 | 0.17;27;10.4 1050 | 0.36;3;10.9 1051 | 0.36;6;10.8 1052 | 0.17;27;10.4 1053 | 0.59;16;9.2 1054 | 0.05;19;12.9 1055 | 0.42;9;12.7 1056 | 0.27;5;9.1 1057 | 0.27;5;9.1 1058 | 0.53;3;12.1 1059 | 0.25;28;9.1 1060 | 0.57;30;11.6 1061 | 0.53;3;12.1 1062 | 0.57;3;9.9 1063 | 0.5;7;12.5 1064 | 0.44;6;11.4 1065 | 0.65;6;11.8 1066 | 0.09;5;11.8 1067 | 0.18;6;10.2 1068 | 0.08;13;12.5 1069 | 0.53;3;10.9 1070 | 0.53;3;10.9 1071 | 0.35;28;10.8 1072 | 0.45;19;11.1 1073 | 0.2;30;9.2 1074 | 0.26;33;9.5 1075 | 0.33;16;10.7 1076 | 0.2;30;9.2 1077 | 0.34;45;10.2 1078 | 0.56;3;11.4 1079 | 0.65;3;11 1080 | 0.65;3;11 1081 | 0.68;37.5;12.3 1082 | 0.56;3;11.8 1083 | 0.68;37.5;12.3 1084 | 0.3;31;9.5 1085 | 0.45;32;12 1086 | 0.3;31;9.5 1087 | 0.08;40;9.6 1088 | 0.4;3;11.6 1089 | 0.42;18;11.2 1090 | 0.54;22;9.9 1091 | 0.54;22;9.9 1092 | 0.54;42;11.8 1093 | 0.42;8;11.4 1094 | 0.09;10;11.5 1095 | 0.36;11;12 1096 | 0.09;9;10.8 1097 | 0.47;6;10.5 1098 | 0.09;9;10.8 1099 | 0.38;5;9.4 1100 | 0.45;5;12.5 1101 | 0.38;5;9.4 1102 | 0.42;23;12.4 1103 | 0.27;14;12 1104 | 0.09;18;11.2 1105 | 0.27;14;12 1106 | 0.34;16;12.4 1107 | 0.28;13;12.8 1108 | 0.42;9;12.3 1109 | 0.41;10;11.7 1110 | 0.1;4;9.5 1111 | 0.43;27;10.8 1112 | 0;6;10 1113 | 0.27;23;12.3 1114 | 0.41;6;11 1115 | 0.39;3;9.5 1116 | 0.5;29;13.6 1117 | 0.07;15;11.3 1118 | 0.07;15;11.3 1119 | 0.07;15;11.3 1120 | 0.12;14;13.3 1121 | 0;7;12.9 1122 | 0.34;8;13.1 1123 | 0;21;12.3 1124 | 0;27;12.3 1125 | 0.37;17;11.2 1126 | 0;3;11.5 1127 | 0.35;13;11.3 1128 | 0.26;3;13.5 1129 | 0;26;11.5 1130 | 0.33;28;10 1131 | 0.35;24;10.5 1132 | 0;5;10.4 1133 | 0.21;57;9.5 1134 | 0.34;18;13.6 1135 | 0.07;10;11.2 1136 | 0.35;6;11.8 1137 | 0.43;22;11.9 1138 | 0.45;6;11.4 1139 | 0.45;6;11.4 1140 | 0.15;29;9.1 1141 | 0.24;16;9.5 1142 | 0.3;33;9.5 1143 | 0.32;24;11 1144 | 0.11;6;11.4 1145 | 0.3;16;10 1146 | 0.23;35;10.1 1147 | 0.43;31;10.4 1148 | 0.12;6;9.8 1149 | 0.45;6;11.8 1150 | 0.42;9;11.6 1151 | 0.47;6;12 1152 | 0.32;4;12.8 1153 | 0.23;16;12.5 1154 | 0.25;9;9.8 1155 | 0.35;17;11.1 1156 | 0;50;11.4 1157 | 0.25;9;9.8 1158 | 0.51;45;11.8 1159 | 0.18;16;12.9 1160 | 0.43;22;10.6 1161 | 0.43;11;10.8 1162 | 0.57;6;11.1 1163 | 0.43;12;10.2 1164 | 0.42;12;11.8 1165 | 0.24;10;10 1166 | 0.24;10;10 1167 | 0.5;15;9.4 1168 | 0.26;7;10.2 1169 | 0.39;29;12.4 1170 | 0.27;8;12 1171 | 0.29;5;11.5 1172 | 0.34;5;10.5 1173 | 0;26;10.8 1174 | 0.46;5;12.3 1175 | 0.31;26;9.5 1176 | 0.31;26;9.5 1177 | 0;48;11.5 1178 | 0.03;23;11.2 1179 | 0;6;12.7 1180 | 0;17;11.4 1181 | 0.33;11;11 1182 | 0.33;11;11 1183 | 0.43;5;11.4 1184 | 0.4;41;10.5 1185 | 0.07;16;9.3 1186 | 0.23;11;10.9 1187 | 0.3;6;11.9 1188 | 0.03;6;12.2 1189 | 0.3;6;11.9 1190 | 0.23;11;10.9 1191 | 0.05;5;9.6 1192 | 0.57;6;12.5 1193 | 0;6;10.8 1194 | 0.37;11;12.4 1195 | 0;6;10.8 1196 | 0.12;15;9.5 1197 | 0.22;21;9.5 1198 | 0.23;23;9.5 1199 | 0.21;4;9.8 1200 | 0.26;19;10.9 1201 | 0.23;23;9.5 1202 | 0.21;4;9.8 1203 | 0.36;5;11.2 1204 | 0.39;6;11.7 1205 | 0.19;33;9.4 1206 | 0.46;24;11 1207 | 0.46;24;11 1208 | 0.46;24;11 1209 | 0.55;24;10 1210 | 0.46;24;11 1211 | 0.43;14;11.2 1212 | 0.02;8;10.4 1213 | 0.15;22;9.3 1214 | 0.02;8;10.4 1215 | 0.42;5;10.5 1216 | 0.46;6;10.4 1217 | 0.46;20;11.3 1218 | 0.31;10;9.5 1219 | 0.37;43;12 1220 | 0.31;8;10.6 1221 | 0.4;25;10.9 1222 | 0.52;17;11.5 1223 | 0.52;17;11.5 1224 | 0.22;33;9.6 1225 | 0.47;9;12 1226 | 0.49;8;10.3 1227 | 0.23;18;9.4 1228 | 0.03;27;9.2 1229 | 0.25;8;9.6 1230 | 0;18;13.6 1231 | 0.29;19;9.5 1232 | 0.34;15;11.8 1233 | 0.01;48;10.8 1234 | 0.29;19;9.5 1235 | 0.37;14;9.3 1236 | 0.01;11;12.8 1237 | 0.32;6;11.5 1238 | 0;7;9.4 1239 | 0.01;11;12.8 1240 | 0;12;9.6 1241 | 0;11;11.8 1242 | 0.2;36;9.3 1243 | 0.39;28;9.8 1244 | 0.41;15;12.2 1245 | 0.22;10;9.5 1246 | 0.25;72;10.3 1247 | 0.19;15;10.5 1248 | 0.07;15;10 1249 | 0.19;15;10.5 1250 | 0.33;22;11.1 1251 | 0.01;24;10.9 1252 | 0.01;24;10.9 1253 | 0.14;27;9.8 1254 | 0;6;9.8 1255 | 0;6;9.5 1256 | 0.06;20;10.9 1257 | 0.02;26;11 1258 | 0.22;43;9.2 1259 | 0.28;12;11 1260 | 0;15;11.3 1261 | 0;15;11.3 1262 | 0.68;19;9.3 1263 | 0;17;11.2 1264 | 0.38;34;9.8 1265 | 0;13;9.6 1266 | 0.32;26;11.8 1267 | 0.05;16;10.3 1268 | 0.05;16;10.3 1269 | 0.5;13;11.4 1270 | 0.31;21;9.5 1271 | 0.03;28;14 1272 | 0.01;26;14 1273 | 0.2;24;11.7 1274 | 0;25;11.2 1275 | 0.2;34;9.3 1276 | 0.13;17;11.2 1277 | 0.22;13;9.5 1278 | 0.4;3;12 1279 | 0;3;9.7 1280 | 0.22;13;9.5 1281 | 0.39;3;11.5 1282 | 0.2;28;10.4 1283 | 0.2;28;10.4 1284 | 0;9;10.9 1285 | 0.28;17;10.2 1286 | 0.19;18;10.9 1287 | 0.5;20;10.5 1288 | 0.44;17;12.4 1289 | 0.08;3;13 1290 | 0.3;20;10.2 1291 | 0.3;20;10.2 1292 | 0;6;11 1293 | 0.1;25;10.9 1294 | 0.13;14;12.4 1295 | 0;6;9.7 1296 | 0.1;25;10.9 1297 | 0;51;9.5 1298 | 0;51;9.5 1299 | 0.14;15;12.1 1300 | 0;11;12.2 1301 | 0;5;10.9 1302 | 0;15;12.5 1303 | 0.07;20;11.7 1304 | 0.32;4;11.2 1305 | 0.44;28;11.2 1306 | 0.21;21;9.2 1307 | 0.26;24;9.8 1308 | 0.32;22;10.1 1309 | 0.09;15;11.1 1310 | 0.32;22;10.1 1311 | 0.1;27;9.2 1312 | 0.26;24;9.8 1313 | 0.15;12;12.8 1314 | 0.21;14;10.5 1315 | 0.21;20;10.1 1316 | 0.21;24;10.1 1317 | 0.27;17;9.8 1318 | 0;16;12.5 1319 | 0.46;10;11.9 1320 | 0.27;17;9.8 1321 | 0.68;18;9.1 1322 | 0.34;12;10.1 1323 | 0;16;12.5 1324 | 0.42;9;11.4 1325 | 0.39;21;11 1326 | 0.24;18;10.6 1327 | 0.24;18;10.6 1328 | 0.24;18;10.6 1329 | 0.24;18;10.6 1330 | 0.11;13;9.3 1331 | 0.26;17;9.8 1332 | 0.26;17;9.8 1333 | 0.26;31;9.2 1334 | 0.1;6;9.7 1335 | 0.22;12;9.6 1336 | 0;4;10 1337 | 0.02;19;12.6 1338 | 0;15;9.5 1339 | 0;15;9.5 1340 | 0;15;9.5 1341 | 0.02;13;10.5 1342 | 0.02;13;10.5 1343 | 0.02;13;10.5 1344 | 0.02;17;10.4 1345 | 0.02;13;10.5 1346 | 0.48;8;11 1347 | 0.24;10;10.2 1348 | 0.01;5;11.4 1349 | 0.03;7;9.5 1350 | 0.03;7;9.5 1351 | 0;21;10.8 1352 | 0.29;32;10 1353 | 0.01;8;11.8 1354 | 0.03;14;10.3 1355 | 0.03;14;10.3 1356 | 0.03;7;10 1357 | 0.25;5;10.1 1358 | 0.25;4;10.1 1359 | 0.24;27;11.1 1360 | 0.17;52;9.5 1361 | 0.4;6;10.0333333333333 1362 | 0.31;11;10.9 1363 | 0.14;13;10.1 1364 | 0.4;6;10.0333333333333 1365 | 0.27;11;9.8 1366 | 0.02;10;11.8 1367 | 0.09;10;9.5 1368 | 0.08;10;9.8 1369 | 0.3;9;10.5 1370 | 0.32;16;9.8 1371 | 0;4;10.4 1372 | 0.51;12;9.2 1373 | 0.56;5;11.6 1374 | 0.51;12;9.2 1375 | 0.27;34;9.3 1376 | 0;16;9.8 1377 | 0.26;13;9.9 1378 | 0.2;7;10 1379 | 0.26;23;12.2 1380 | 0.15;10;9.9 1381 | 0.02;11;10.8 1382 | 0.02;11;10.8 1383 | 0.09;4;9.6 1384 | 0.22;25;9.9 1385 | 0.22;25;9.9 1386 | 0.15;20;9.5 1387 | 0.25;34;9.2 1388 | 0.07;8;9.6 1389 | 0.07;8;9.6 1390 | 0.31;7;10.3 1391 | 0.02;36;9.7 1392 | 0;15;12.5 1393 | 0.22;5;11 1394 | 0.06;5;9.8 1395 | 0.25;19;10.2 1396 | 0.14;27;9.2 1397 | 0.1;3;9.55 1398 | 0.1;4;9.55 1399 | 0.26;17;9.9 1400 | 0.12;13;10.2 1401 | 0;10;11.1 1402 | 0.21;33;9.9 1403 | 0.21;33;9.9 1404 | 0.42;6;11.9 1405 | 0.33;3;10 1406 | 0.39;12;10.7 1407 | 0.3;18;11.3 1408 | 0.34;8;10.9 1409 | 0;40;10.7 1410 | 0.36;35;12.4 1411 | 0;40;10.7 1412 | 0;5;11.9 1413 | 0.4;8;10.6 1414 | 0.34;8;10.9 1415 | 0.25;12;10.1 1416 | 0.59;3;9.6 1417 | 0;8;9.4 1418 | 0.59;3;9.6 1419 | 0.33;21;12.1 1420 | 0.01;3;9.8 1421 | 0.21;32;9.9 1422 | 0.01;3;9.8 1423 | 0.18;24;9.4 1424 | 0;39;11.4 1425 | 0.09;14;11 1426 | 0.37;8;9.6 1427 | 0.37;8;9.6 1428 | 0.37;23;12.1 1429 | 0.33;6;11.2 1430 | 0;27;11 1431 | 0.4;38;11.3 1432 | 0.24;18;10.4 1433 | 0.31;13;9.9 1434 | 0;3;11.7 1435 | 0.16;11;10.1 1436 | 0.37;55;9 1437 | 0.37;55;9 1438 | 0.38;27;8.5 1439 | 0.29;15;11.1 1440 | 0;3;10.3 1441 | 0.02;31;11.0666666666667 1442 | 0.32;15;11.3 1443 | 0.19;19;9.56666666666667 1444 | 0.02;18;9.8 1445 | 0.2;8;11.7 1446 | 0.02;31;11.1 1447 | 0.19;19;9.6 1448 | 0.02;18;9.8 1449 | 0;22;9.7 1450 | 0.01;40;9.7 1451 | 0.31;15;11.3 1452 | 0.32;15;11.3 1453 | 0.44;8;11 1454 | 0.02;37;11.6 1455 | 0.33;27;9 1456 | 0.63;7;10.9 1457 | 0;9;10.9 1458 | 0.06;38;10.55 1459 | 0.33;27;9 1460 | 0.4;8;10.5 1461 | 0.35;7;11.9 1462 | 0.09;34;10.4 1463 | 0;6;10 1464 | 0.03;14;10.4 1465 | 0.01;14;10.8 1466 | 0.1;34;9.7 1467 | 0.1;34;9.7 1468 | 0.32;31;10 1469 | 0.08;19;11 1470 | 0.32;31;10 1471 | 0.05;20;9.7 1472 | 0.11;8;9.7 1473 | 0.08;8;12.6 1474 | 0.6;23;11.1 1475 | 0.08;14;11 1476 | 0.5;48;8.8 1477 | 0.11;16;13.5666666666667 1478 | 0.5;48;8.8 1479 | 0.11;16;13.6 1480 | 0.05;3;10.2 1481 | 0.6;10;10.6 1482 | 0.03;6;10.1 1483 | 0.6;10;10.6 1484 | 0.54;3;10.3 1485 | 0.44;6;10.7 1486 | 0.06;4;10.9 1487 | 0.16;8;9.7 1488 | 0.21;9;10.3 1489 | 0.05;9;10.6 1490 | 0.04;5;11.4 1491 | 0.1;4;10.8 1492 | 0.49;8;12.4 1493 | 0.04;5;11.4 1494 | 0.06;6;11.95 1495 | 0.26;23;9.7 1496 | 0.09;15;10 1497 | 0.02;15;10.6 1498 | 0.26;23;9.7 1499 | 0.03;7;11.5 1500 | 0.04;7;10.8 1501 | 0.03;7;11.5 1502 | 0.04;8;9.6 1503 | 0.29;21;9.4 1504 | 0.18;15;9.8 1505 | 0.39;6;11 1506 | 0.57;5;11.4 1507 | 0.02;6;9.95 1508 | 0.05;6;10.8 1509 | 0.57;5;11.4 1510 | 0.6;17;10.6 1511 | 0.4;7;11.1 1512 | 0.21;26;9.7 1513 | 0.04;19;9.8 1514 | 0.04;11;10.4 1515 | 0.15;17;10.5 1516 | 0.21;16;9.23333333333333 1517 | 0.21;16;9.25 1518 | 0.25;23;10.6 1519 | 0.06;29;10.3 1520 | 0.46;7;10.5 1521 | 0.08;14;10.2 1522 | 0.06;29;10.3 1523 | 0.2;9;9.05 1524 | 0.25;23;10.6 1525 | 0.25;29;10.4 1526 | 0.19;22;10 1527 | 0.08;18;9.7 1528 | 0.08;18;9.6 1529 | 0.07;15;10.8 1530 | 0.49;21;10.1 1531 | 0.08;42;10.2 1532 | 0.09;9;11.3 1533 | 0.1;13;10.2 1534 | 0.13;18;9.9 1535 | 0.3;32;9 1536 | 0.14;13;11.7 1537 | 0.13;15;9.7 1538 | 0.08;24;10.3 1539 | 0.08;20;10.2 1540 | 0.09;15;12 1541 | 0.32;34;9.9 1542 | 0.08;11;11.6 1543 | 0.29;19;10.9 1544 | 0.02;29;10.75 1545 | 0.42;14;10.4 1546 | 0.43;12;11.2 1547 | 0.33;16;10.1 1548 | 0.02;17;10.2 1549 | 0.1;12;12.1 1550 | 0.5;19;10.4 1551 | 0.3;17;11.4 1552 | 0;17;9.5 1553 | 0;18;9.4 1554 | 0.01;32;11.3 1555 | 0;18;9.4 1556 | 0.02;15;11 1557 | 0.17;15;10.55 1558 | 0.04;12;9.9 1559 | 0.02;15;11 1560 | 0.33;66;9.5 1561 | 0.26;31;9.9 1562 | 0.26;31;9.9 1563 | 0.26;31;9.9 1564 | 0.13;12;10.1 1565 | 0.13;12;10.1 1566 | 0.13;12;10.1 1567 | 0.02;26;10.9 1568 | 0.64;24;11.2 1569 | 0.13;12;10.1 1570 | 0.13;25;9.2 1571 | 0.14;15;11.5 1572 | 0.53;19;12.4 1573 | 0.14;15;11.1 1574 | 0.32;35;9.5 1575 | 0.2;15;12.5 1576 | 0.78;23;10.5 1577 | 0.4;12;11.8 1578 | 0.63;16;10.8 1579 | 0.15;13;11.9 1580 | 0.15;13;11.3 1581 | 0.09;24;11.3 1582 | 0.33;9;11.9 1583 | 0.09;24;11.3 1584 | 0.1;13;11.9 1585 | 0.29;32;9.8 1586 | 0.44;24;11.6 1587 | 0.44;22;11.5 1588 | 0.41;34;11.4 1589 | 0.11;18;10.9 1590 | 0.33;34;12.8 1591 | 0.2;29;9.2 1592 | 0.15;26;11.6 1593 | 0.09;16;11.6 1594 | 0.13;29;11 1595 | 0.08;28;9.5 1596 | 0.08;32;10.5 1597 | 0.1;39;11.2 1598 | 0.13;29;11 1599 | 0.12;32;10.2 1600 | 0.47;18;11 1601 | -------------------------------------------------------------------------------- /Chapter08/savetuple.csv: -------------------------------------------------------------------------------- 1 | ColName A, ColName B, ColName C 2 | 0.5759616979698472,0.2597832683075949,0.6763647042230778 3 | 0.22641093419831848,0.25330112037052377,0.4254329735280291 4 | 0.24038682826261226,0.1489904275220344,0.34554192821813756 5 | 0.9047742467024442,0.4762523428683665,0.6555721751023464 6 | 0.7066097540260676,0.9228117851885098,0.6047681786507859 7 | 0.5698373969395576,0.19760388845977572,0.5378556937343291 8 | 0.5491000961739994,0.34557957137077056,0.38959869748190834 9 | 0.9265060082894219,0.6453628734073003,0.7124738625032145 10 | 0.6257468517955809,0.6167041462077394,0.7780396915716952 11 | 0.24328325235841408,0.3186172478161837,0.6129606280610105 12 | -------------------------------------------------------------------------------- /Chapter08/tcpserver.jl: -------------------------------------------------------------------------------- 1 | using Sockets 2 | server = Sockets.listen(8080) 3 | # Sockets.TCPServer(Base.Libc.WindowsRawSocket(0x00000000000002e4) active) 4 | 5 | conn = accept(server) 6 | # on the client: $ nc localhost 8080 7 | # TcpSocket(connected,0 bytes waiting) 8 | line = readline(conn) 9 | # hello Julia server! 10 | # "hello Julia server!\n" 11 | write(conn, "Hello back from server to client, what can I do for you?") 12 | 56 13 | close(conn) -------------------------------------------------------------------------------- /Chapter08/tuple_csv.jl: -------------------------------------------------------------------------------- 1 | fname = "savetuple.csv" 2 | csvfile = open(fname,"w") 3 | # writing headers: 4 | write(csvfile, "ColName A, ColName B, ColName C\n") 5 | for i = 1:10 6 | tup(i) = tuple(rand(Float64,3)...) 7 | write(csvfile, join(tup(i),","), "\n") 8 | end 9 | close(csvfile) -------------------------------------------------------------------------------- /Chapter09/array_product_benchmark.jl: -------------------------------------------------------------------------------- 1 | # The following benchmarks demonstrate 2 | # that devectorising code can lead to substantial speed improvement 3 | x = randn(10000000) 4 | y = randn(10000000) 5 | 6 | function inner(x, y) 7 | result = 0.0 8 | for i=1:length(x) 9 | result += x[i] * y[i] 10 | end 11 | result 12 | end 13 | 14 | # GC.enable(false) 15 | @time for i=1:50 result = sum(x .* y); end 16 | # with 1 processor: Array operations took 89.43973046 ms - avg: 90 ms 17 | # with 9 processors: 4.895387 seconds (336.22 k allocations: 3.742 GiB, 20.99% gc time) 18 | 19 | @time for i=1:50 result = inner(x, y) end 20 | # 0.967685 seconds (14.13 k allocations: 746.626 KiB) 21 | 22 | x = randn(1, 10000000) 23 | y = randn(10000000, 1) 24 | 25 | @time for i=1:50 result = x * y end 26 | # 2.815247 seconds (927.43 k allocations: 44.635 MiB, 0.83% gc time) 27 | -------------------------------------------------------------------------------- /Chapter09/callc.jl: -------------------------------------------------------------------------------- 1 | # calling a function in a shared library: 2 | lang = ccall( (:getenv, "libc"), Cstring, (Cstring,), "LANGUAGE") 3 | unsafe_string(lang) #> "en_US" 4 | 5 | # test existence of library: 6 | find_library(["libc"]) #> "libc" -------------------------------------------------------------------------------- /Chapter09/callpy.jl: -------------------------------------------------------------------------------- 1 | using PyCall 2 | py"10*10" #> 100 3 | @pyimport math 4 | math.sin(math.pi / 2) #> 1.0 5 | -------------------------------------------------------------------------------- /Chapter09/file1.txt: -------------------------------------------------------------------------------- 1 | This a a test for try / catch / finally -------------------------------------------------------------------------------- /Chapter09/file2.txt: -------------------------------------------------------------------------------- 1 | Julia RustJulia Rust -------------------------------------------------------------------------------- /Chapter09/performance.jl: -------------------------------------------------------------------------------- 1 | # TIPS: 2 | # 1 3 | const DEFAULT = 42 4 | 5 | global x = 42 6 | function f(args) 7 | #function body 8 | end 9 | y = f(x::Int + 1) 10 | 11 | # 3 12 | function myFunc(a::T, c::Int) where T 13 | # code 14 | end 15 | 16 | # 9 17 | function with_keyword(x; name::String = "Smith") 18 | # ... 19 | end 20 | 21 | # 16 22 | mutable struct Person 23 | name::String 24 | height::Float64 25 | weight::Float64 26 | end 27 | # instead of: 28 | # type Person 29 | # name 30 | # height 31 | # weight 32 | # end 33 | 34 | # 18 35 | # Use 36 | file = open("file2.txt", "w") 37 | a = "Julia" 38 | b = "Rust" 39 | write(file, a, " ", b) 40 | # instead of: 41 | write(file, "$a $b") 42 | 43 | # TOOLS: 44 | # @time 45 | 46 | # linter: 47 | # add Lint 48 | # using Lint 49 | # lintfile("performance.jl") -------------------------------------------------------------------------------- /Chapter09/shell.jl: -------------------------------------------------------------------------------- 1 | pwd() 2 | # cd("d:\\test\\week1") 3 | # shell mode: 4 | # ; ls (on Linux and mac OS X) 5 | # ; mkdir folder 6 | # ; cd folder 7 | 8 | # on Linux and mac OS X: 9 | cmd = `echo Julia is smart` 10 | typeof(cmd) #> Cmd (constructor with 1 method) 11 | run(cmd) #> Julia is smart 12 | run(`date`) #> Sun Oct 12 09:44:50 GMT 2014 13 | cmd = `cat file1.txt` 14 | run(cmd) #> text from file1.txt: This a a test for try / catch / finally 15 | success(cmd) #> true 16 | 17 | # interpolation: 18 | file = "file1.txt" 19 | cmd = `cat $file` 20 | run(cmd) #> text from file1.txt: This a a test for try / catch / finally 21 | # cmd = `ls *.*` # works only on Windows 22 | # run(cmd) #> returns: file1.txt shell.jl test.txt 23 | # pipelining: 24 | run(pipeline(`cat $file`,"test.txt")) #> text from file1.txt is written into test.txt 25 | run(pipeline("test.txt",`cat`)) 26 | run(pipeline(`echo $("\nhi\nJulia")`,`cat`,`grep -n J`)) #> 3:Julia 27 | run(pipeline(`cat "tosort.txt"`,`sort`)) # returns A B C 28 | 29 | println() 30 | println("Output grep command:") 31 | # output: 32 | # run(`grep is $(readdir())`) # returns where "is" is found in text files in current dir 33 | #= 34 | array_product_benchmark.jl:# gc_disable() 35 | callc.jl:# test existence of library: 36 | file1.txt:This a a test for try / catch / finally 37 | performance.jl:foo1(x::Int) = isprime(x) ? x: false 38 | shell.jl:cmd = `echo Julia is smart` 39 | shell.jl:run(cmd) #> Julia is smart 40 | shell.jl:run(cmd) #> text from file1.txt: This a a test for try / catch / finally 41 | 42 | shell.jl:run(cmd) #> text from file1.txt: This a a test for try / catch / finally 43 | 44 | shell.jl:run(`cat $file` |> "test.txt") #> text from file1.txt is written into te 45 | st.txt 46 | shell.jl:run(`grep is $(readdir())`) # returns where "is" is found in text files 47 | in current dir 48 | shell.jl:# CThis a a test for try / catch / finally 49 | test.txt:This a a test for try / catch / finally 50 | =# 51 | println() 52 | 53 | # reading the output of the command: 54 | a = readall(pipeline(`cat "tosort.txt"`,`sort`)) 55 | #> a has value "A\r\nB\r\nC\n" 56 | 57 | run(`cat "file1.txt"` & `cat "tosort.txt"`) 58 | # B 59 | # A 60 | # CThis a a test for try / catch / finally 61 | 62 | # platform variations: 63 | Sys.KERNEL #> :NT 64 | fun1 = () 65 | fun2 = () 66 | Sys.iswindows() ? fun1 : fun2 67 | if Sys.iswindows() 68 | fun1 69 | else 70 | fun2 71 | end -------------------------------------------------------------------------------- /Chapter09/test.txt: -------------------------------------------------------------------------------- 1 | This a a test for try / catch / finally -------------------------------------------------------------------------------- /Chapter09/tosort.txt: -------------------------------------------------------------------------------- 1 | B 2 | A 3 | C -------------------------------------------------------------------------------- /Chapter10/plots_iris.jl: -------------------------------------------------------------------------------- 1 | using StatPlots, RDatasets 2 | iris = dataset("datasets", "iris") 3 | @df iris scatter(:SepalLength, :SepalWidth, group=:Species, 4 | m=(0.5, [:+ :h :star7], 4), bg=RGB(1.0,1.0,1.0)) -------------------------------------------------------------------------------- /Chapter10/stlib.jl: -------------------------------------------------------------------------------- 1 | filter(x -> iseven(x), 1:10) 2 | # 5-element Array{Int64,1}: 3 | # 2 4 | # 4 5 | # 6 6 | # 8 7 | # 10 8 | mapreduce(x -> sqrt(x), +, 1:10) #> 22.4682781862041 9 | # equivalent to: 10 | sum(map(x -> sqrt(x), 1:10)) #> 22.4682781862041 11 | 12 | # clipboard: 13 | using InteractiveUtils 14 | a = 42 #> 42 15 | clipboard(a) 16 | # quit and restart REPL: 17 | # a #> ERROR: a not defined 18 | a = clipboard() #> "42" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Julia 1.0 Programming - Second Edition 2 | 3 | Julia 1.0 Programming - Second Edition 4 | 5 | This is the code repository for [Julia 1.0 Programming - Second Edition](https://www.packtpub.com/application-development/julia-10-programming-second-edition?utm_source=github&utm_medium=repository&utm_campaign=9781788999090), published by Packt. 6 | 7 | **Enter the exciting world of Julia, a high-performance language for technical computing** 8 | 9 | ## What is this book about? 10 | The release of Julia 1.0 is now ready to change the technical world by combining the high productivity and ease of use of Python and R with the lightning-fast speed of C++. Julia 1.0 programming gives you a head start in tackling your numerical and data problems. You will begin by learning how to set up a running Julia platform, before exploring its various built-in types. With the help of practical examples, this book walks you through two important collection types: arrays and matrices. In addition to this, you will be taken through how type conversions and promotions work. 11 | 12 | This book covers the following exciting features: 13 | * Set up your Julia environment to achieve high productivity 14 | * Create your own types to extend the built-in type system 15 | * Visualize your data in Julia with plotting packages 16 | * Explore the use of built-in macros for testing and debugging, among other uses 17 | * Apply Julia to tackle problems concurrently 18 | Integrate Julia with other languages such as C, Python, and MATLAB 19 | 20 | If you feel this book is for you, get your [copy](https://www.amazon.com/dp/B07GVN47MR) today! 21 | 22 | https://www.packtpub.com/ 24 | 25 | ## Instructions and Navigations 26 | All of the code is organized into folders. For example, Chapter02. 27 | 28 | The code will look like the following: 29 | ``` 30 | for arg in ARGS 31 | println(arg) 32 | end 33 | ``` 34 | 35 | **Following is what you need for this book:** 36 | This book is intended for data scientists and all those who work on technical and scientific computation projects. It will get you up and running quickly with Julia to start simplifying your projects' applications. The book assumes you already have some basic working knowledge of a high-level dynamic language such as MATLAB, R, Python, or Ruby. 37 | 38 | With the following software and hardware list you can run all code files present in the book (Chapter 1-10). 39 | ### Software and Hardware List 40 | | Chapter | Software required | OS required | 41 | | -------- | ------------------------------------ | ----------------------------------- | 42 | | All | Julia v1.0 | Windows, Linux, macOS | 43 | 44 | ### Related products 45 | * Learning Julia [[Packt]](https://www.packtpub.com/application-development/learning-julia?utm_source=github&utm_medium=repository&utm_campaign=9781785883279) [[Amazon]](https://www.amazon.com/dp/1785883275) 46 | 47 | * Hands-On Computer Vision with Julia [[Packt]](https://www.packtpub.com/application-development/hands-computer-vision-julia?utm_source=github&utm_medium=repository&utm_campaign=9781788998796) [[Amazon]](https://www.amazon.com/dp/1788998790) 48 | 49 | ## Get to Know the Author 50 | **Ivo Balbaert** 51 | has been a lecturer in web programming and databases at CVO Antwerpen, a community college in Belgium. He received a Ph.D. in Applied Physics from the University of Antwerp in 1986. He worked for 20 years in the software industry as a developer and consultant in several companies, and for 10 years as project manager at the University Hospital of Antwerp. From 2000 onwards, he switched to partly teaching and partly developing software (at KHM Mechelen, CVO Antwerpen). He also wrote an introductory book in Dutch about developing in Ruby and Rails, Programmeren met Ruby en Rails, by Van Duuren Media. In 2012, he authored a book on the Go programming language, The Way To Go, by IUniverse. He wrote a number of introductory books for new programming languages, notably Dart, Julia, Rust, and Red, all published by Packt. 52 | 53 | ## Get to Know the Author 54 | **Ivo Balbaert** 55 | has been a lecturer in web programming and databases at CVO Antwerpen, a community college in Belgium. He received a Ph.D. in Applied Physics from the University of Antwerp in 1986. He worked for 20 years in the software industry as a developer and consultant in several companies, and for 10 years as project manager at the University Hospital of Antwerp. From 2000 onwards, he switched to partly teaching and partly developing software (at KHM Mechelen, CVO Antwerpen). He also wrote an introductory book in Dutch about developing in Ruby and Rails, Programmeren met Ruby en Rails, by Van Duuren Media. In 2012, he authored a book on the Go programming language, The Way To Go, by IUniverse. He wrote a number of introductory books for new programming languages, notably Dart, Julia, Rust, and Red, all published by Packt. 56 | 57 | ## Other books by the authors 58 | [Learning Dart ](https://www.packtpub.com/web-development/learning-dart?utm_source=github&utm_medium=repository&utm_campaign=9781849697422) 59 | 60 | [Dart Cookbook](https://www.packtpub.com/web-development/dart-cookbook?utm_source=github&utm_medium=repository&utm_campaign=9781783989621) 61 | 62 | [Getting Started with Julia](https://www.packtpub.com/application-development/getting-started-julia?utm_source=github&utm_medium=repository&utm_campaign=9781783284795) 63 | 64 | [Rust Essentials](https://www.packtpub.com/application-development/rust-essentials?utm_source=github&utm_medium=repository&utm_campaign=9781785285769) 65 | 66 | [Learning Dart - Second Edition](https://www.packtpub.com/web-development/learning-dart-second-edition?utm_source=github&utm_medium=repository&utm_campaign=9781785287626) 67 | 68 | ### Suggestions and Feedback 69 | [Click here](https://docs.google.com/forms/d/e/1FAIpQLSdy7dATC6QmEL81FIUuymZ0Wy9vH1jHkvpY57OiMeKGqib_Ow/viewform) if you have any feedback or suggestions. 70 | 71 | 72 | --------------------------------------------------------------------------------