[ADD] strings in Julia

This commit is contained in:
Eduardo Cueto Mendoza 2020-05-04 16:13:42 -06:00
parent 2e47abdfdf
commit 53cc7a6354
1 changed files with 50 additions and 0 deletions

50
01_Strings.jl Executable file
View File

@ -0,0 +1,50 @@
println("hello world")
println(isempty(""))
println(string(true))
println(typeof('a'))
println(Char(97))
println(string(12, " stuff ", true))
engine = "merlin"
thrust = 845
println(string(engine, " has ", thrust, " kN thrust"))
println("$engine has $(thrust)kN thrust")
println("1/3 is about $(1/3)")
#@sprintf("1/3 is about %2.4f",1/3)
println("123"[1])
batman = "Bruce Wayne"
println(batman[1:5])
println(batman[7:end])
println(batman[[1,2]])
println(batman[[1,8]])
println(batman[7:2:11])
println(length("pal"))
println(length("pål"))
println("pål"[2])
println("pål"[4])
println(sizeof("pal"))
println(sizeof("pål"))
println(b"pal")
println(map(dec, b"pal"))
println(map(dec, b"pål"))
println(map(Char, b"pål"))
println(map(Char, b"pal"))
println(chr2ind("pål",1))
println(chr2ind("pål",2))
println(chr2ind("pål",3))
println(next("pål",2))
println(endof("pål"))
println(lowercase("HELLO"))
println(replace("I want to go to Mars", "Mars", "Venus"))
println("iron" * "man")
println("ironman"[1:4] * "girl")
println(search("curiosity rover has landed", "rover"))
println(search("curiosity rover has landed", "vega 1"))
println(startswith(strip(" julia> 3 + 5 "), "julia"))
#println(strip(" julia> 3 + 5 "))
s = split("one two three")
println(s)
println(join(s, " "))
println("abc" < "bbc")
println("abc" > "bbc")