From 960ee4a1856db8eadb96277bb2422edfa8f2a81c Mon Sep 17 00:00:00 2001 From: Gabriel Halley Date: Wed, 7 Oct 2015 23:11:24 -0400 Subject: removing whitespace all over --- julia.html.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index 5ccd6484..66329feb 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -14,7 +14,7 @@ This is based on Julia 0.3. # Single line comments start with a hash (pound) symbol. #= Multiline comments can be written - by putting '#=' before the text and '=#' + by putting '#=' before the text and '=#' after the text. They can also be nested. =# @@ -670,7 +670,7 @@ square_area(l) = l * l # square_area (generic function with 1 method) square_area(5) #25 # What happens when we feed square_area an integer? -code_native(square_area, (Int32,)) +code_native(square_area, (Int32,)) # .section __TEXT,__text,regular,pure_instructions # Filename: none # Source line: 1 # Prologue @@ -703,10 +703,10 @@ code_native(square_area, (Float64,)) # vmulsd XMM0, XMM0, XMM0 # Scalar double precision multiply (AVX) # pop RBP # ret - # + # # Note that julia will use floating point instructions if any of the # arguements are floats. -# Let's calculate the area of a circle +# Let's calculate the area of a circle circle_area(r) = pi * r * r # circle_area (generic function with 1 method) circle_area(5) # 78.53981633974483 @@ -737,7 +737,7 @@ code_native(circle_area, (Float64,)) # vmulsd XMM0, XMM1, XMM0 # pop RBP # ret - # + # ``` ## Further Reading -- cgit v1.2.3 From 77f0219cc6fd64f9c4dbd3007fa395b2242a6e49 Mon Sep 17 00:00:00 2001 From: Ratan Date: Sat, 10 Oct 2015 12:10:27 -0400 Subject: change String to AbstractString as per 0.4 spec --- julia.html.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index 66329feb..7ca2d492 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -78,7 +78,7 @@ false 1 < 2 < 3 # => true 2 < 3 < 2 # => false -# Strings are created with " +# AbstractStrings are created with " "This is a string." # Character literals are written with ' @@ -314,7 +314,7 @@ end # For loops iterate over iterables. -# Iterable types include Range, Array, Set, Dict, and String. +# Iterable types include Range, Array, Set, Dict, and AbstractString. for animal=["dog", "cat", "mouse"] println("$animal is a mammal") # You can use $ to interpolate variables or expression into strings @@ -550,13 +550,13 @@ super(Any) # => Any # <: is the subtyping operator type Lion <: Cat # Lion is a subtype of Cat mane_color - roar::String + roar::AbstractString end # You can define more constructors for your type # Just define a function of the same name as the type # and call an existing constructor to get a value of the correct type -Lion(roar::String) = Lion("green",roar) +Lion(roar::AbstractString) = Lion("green",roar) # This is an outer constructor because it's outside the type definition type Panther <: Cat # Panther is also a subtype of Cat -- cgit v1.2.3 From d673dd62afc5a989b50001b29a59c813643e393f Mon Sep 17 00:00:00 2001 From: Ratan Date: Sat, 10 Oct 2015 14:34:55 -0400 Subject: try to make string change clearer --- julia.html.markdown | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index 7ca2d492..c5089dc3 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -78,13 +78,16 @@ false 1 < 2 < 3 # => true 2 < 3 < 2 # => false -# AbstractStrings are created with " +# Strings are created with " "This is a string." +# Julia has several types of strings, including ASCIIString and UTF8String. +# More on this in the Types section. + # Character literals are written with ' 'a' -# A string can be indexed like an array of characters +# Some strings can be indexed like an array of characters "This is a string"[1] # => 'T' # Julia indexes from 1 # However, this is will not work well for UTF8 strings, # so iterating over strings is recommended (map, for loops, etc). @@ -537,6 +540,17 @@ subtypes(Number) # => 6-element Array{Any,1}: # Real subtypes(Cat) # => 0-element Array{Any,1} +# AbstractString, as the name implies, is also an abstract type +subtypes(AbstractString) # 8-element Array{Any,1}: + # Base.SubstitutionString{T<:AbstractString} + # DirectIndexString + # RepString + # RevString{T<:AbstractString} + # RopeString + # SubString{T<:AbstractString} + # UTF16String + # UTF8String + # Every type has a super type; use the `super` function to get it. typeof(5) # => Int64 super(Int64) # => Signed @@ -546,6 +560,10 @@ super(Number) # => Any super(super(Signed)) # => Number super(Any) # => Any # All of these type, except for Int64, are abstract. +typeof("fire") # => ASCIIString +super(ASCIIString) # => DirectIndexString +super(DirectIndexString) # => AbstractString +# Likewise here with ASCIIString # <: is the subtyping operator type Lion <: Cat # Lion is a subtype of Cat -- cgit v1.2.3 From 56e8508a303950ea7f3c9da47773c00a877d6625 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Fri, 16 Oct 2015 12:25:19 +1100 Subject: Update Julia variable names Julia supports underscores at the beginning of a variable name now. It also supports a subset of Unicode code points for the first character, and additional code points for subsequent characters. A full explanation of all available code points was excluded as it is quite complicated and doesn't add much value in the X in Y context. closes #516 --- julia.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index c5089dc3..cba7cd45 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -117,11 +117,11 @@ catch e println(e) end -# Variable names start with a letter. +# Variable names start with a letter or underscore. # After that, you can use letters, digits, underscores, and exclamation points. SomeOtherVar123! = 6 # => 6 -# You can also use unicode characters +# You can also use certain unicode characters ☃ = 8 # => 8 # These are especially handy for mathematical notation 2 * π # => 6.283185307179586 -- cgit v1.2.3 From b42f739fa4422fb947f681b5716ae3644014ebf2 Mon Sep 17 00:00:00 2001 From: Pranit Bauva Date: Sun, 1 Nov 2015 02:54:52 +0530 Subject: Fix a typo is julia.html.markdown --- julia.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index cba7cd45..675cf5d3 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -723,7 +723,7 @@ code_native(square_area, (Float64,)) # ret # # Note that julia will use floating point instructions if any of the -# arguements are floats. +# arguments are floats. # Let's calculate the area of a circle circle_area(r) = pi * r * r # circle_area (generic function with 1 method) circle_area(5) # 78.53981633974483 -- cgit v1.2.3 From b8999e88ed3d9317725c79987a379871a6eb8988 Mon Sep 17 00:00:00 2001 From: Pranit Bauva Date: Sun, 1 Nov 2015 03:06:03 +0530 Subject: Add Pranit Bauva to the contributors list of julia.html.markdown --- julia.html.markdown | 1 + 1 file changed, 1 insertion(+) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index 675cf5d3..220b52a4 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -2,6 +2,7 @@ language: Julia contributors: - ["Leah Hanson", "http://leahhanson.us"] + - ["Pranit Bauva", "http://github.com/pranitbauva1997"] filename: learnjulia.jl --- -- cgit v1.2.3 From 20f8f41ad5631f6638d42aca88ad2e0590abbccb Mon Sep 17 00:00:00 2001 From: Pranit Bauva Date: Wed, 4 Nov 2015 22:15:59 +0530 Subject: Add description that strings can be lexicographically compared with comparison operators --- julia.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index cba7cd45..2fedcfd8 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -102,6 +102,11 @@ false # Printing is easy println("I'm Julia. Nice to meet you!") +# String can be compared lexicographically compared +"good" > "bye" # => true +"good" == "good" # => true +"1 + 2 = 3" == "1 + 2 = $(1+2)" # => true + #################################################### ## 2. Variables and Collections #################################################### -- cgit v1.2.3 From a6927f543ce6aee3ed409d7c88fc3695163c6609 Mon Sep 17 00:00:00 2001 From: Pranit Bauva Date: Wed, 4 Nov 2015 23:04:42 +0530 Subject: Add description about compact assignment of functions --- julia.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index 2fedcfd8..a9eed2da 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -395,6 +395,10 @@ end add(5, 6) # => 11 after printing out "x is 5 and y is 6" +# Compact assignment of functions +f_add(x, y) = x + y # => "f (generic function with 1 method)" +f_add(3, 4) # => 7 + # You can define functions that take a variable number of # positional arguments function varargs(args...) -- cgit v1.2.3 From a00cc7127170fe47203900d1ab1aac998501e6ec Mon Sep 17 00:00:00 2001 From: Pranit Bauva Date: Wed, 4 Nov 2015 23:05:47 +0530 Subject: Add description about multiple return values --- julia.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index a9eed2da..1a698834 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -399,6 +399,10 @@ add(5, 6) # => 11 after printing out "x is 5 and y is 6" f_add(x, y) = x + y # => "f (generic function with 1 method)" f_add(3, 4) # => 7 +# Function can also return multiple values as tuple +f(x, y) = x + y, x - y +f(3, 4) # => (7, -1) + # You can define functions that take a variable number of # positional arguments function varargs(args...) -- cgit v1.2.3 From eee0aba489080a13cdca80af46c3128997d792b3 Mon Sep 17 00:00:00 2001 From: Pranit Bauva Date: Mon, 9 Nov 2015 10:33:22 +0530 Subject: Remove the extra 'compared' in julia.html.markdown --- julia.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index 1a698834..fcfa7e30 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -102,7 +102,7 @@ false # Printing is easy println("I'm Julia. Nice to meet you!") -# String can be compared lexicographically compared +# String can be compared lexicographically "good" > "bye" # => true "good" == "good" # => true "1 + 2 = 3" == "1 + 2 = $(1+2)" # => true -- cgit v1.2.3