Last active
September 19, 2022 13:12
-
-
Save Patrikios/e85736caef18f5ebd52fc43c5d382b71 to your computer and use it in GitHub Desktop.
Revisions
-
Patrikios revised this gist
Sep 19, 2022 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,5 +24,8 @@ r2 = [r.first, r.second] uppercase(r2) # ERROR uppercase.(r2) # 2-element Vector{String}: # "PAT" # "MAT" uppercase(r) # ERROR -
Patrikios revised this gist
Sep 19, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,8 @@ p = "foo" => 7 for x in p println(x) end # foo # 7 # but a Pair is treated as a single "scalar" for broadcasting operations r = "Pat" => "Mat" r2 = [r.first, r.second] -
Patrikios created this gist
Sep 19, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ a_tuple = (1, 2) a_pair = 1 => 2 a_tuple != a_pair # true # The elements are stored in the fields first and second a_pair.first # 1 a_pair.second # 1 typeof(a_pair) # Pair{Int64, Int64} # construct pair with 'Pair' keyword Pair(1, 32.1) # They can also be accessed via iteration p = "foo" => 7 for x in p println(x) end # but a Pair is treated as a single "scalar" for broadcasting operations r = "Pat" => "Mat" r2 = [r.first, r.second] uppercase(r2) # ERROR uppercase.(r2) uppercase(r) # ERROR