Skip to content

Instantly share code, notes, and snippets.

@Ismael-VC
Created February 3, 2014 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ismael-VC/8777076 to your computer and use it in GitHub Desktop.
Save Ismael-VC/8777076 to your computer and use it in GitHub Desktop.
String concatenation demo in Julia with the *= operator.
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
ismaelvc@toybox ~> julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-prerelease+1316 (2014-01-30 05:22 UTC)
_/ |\__'_|_|_|\__'_| | Commit d77f95a* (3 days old master)
|__/ | i686-pc-linux-gnu
julia> function test()
accumulator = ""
string_array = ["Hello", " ", "world!"]
for str in string_array
accumulator *= str
end
println(accumulator)
end
test (generic function with 1 method)
julia> # First time it auto-compiles
julia> @time test()
Hello world!
elapsed time: 0.036818582 seconds (117040 bytes allocated)
julia> # Second time uses compiled code
julia> @time test()
Hello world!
elapsed time: 0.000442863 seconds (288 bytes allocated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment