test_julia_scripts/01_Strings.jl

51 lines
1.3 KiB
Julia
Executable File

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")