Leo Dorst & Steven De Keninck have posted a tutorial and javascript code to animate a hypercube dangling from an elastic string and I’m in the process of porting that code to Julia.
The following is their code to generate the vertices of the hypercube. The first three lines generate the coordinates and the last line converts those coordinates to geometric algebra expressions.
var p = [...Array(2**d)] // correct number of points
.map((x,i)=>('000000'+i.toString(2)).slice(-d)) // convert to binary
.map(x=>x.split('').map(v=>v-0.5)) // split and center
.map(x=>!(1e0 + x*[1e1,1e2,1e3,1e4,1e5].slice(0,d))); // convert to PGA points
In my port of generating the coordinates, I’m wondering if there is a similar way in Julia to continue a line at a ‘.’ instead of having a bunch of temporary variables or a very long line as in the following code:
# wfs: physics simulation of Wire Frame on String
function wfs(nD::Int64=2)
# generate vertices of wireframe
BS = bitstring.(Int8.(0:2^nD-1))
print("BS: "); display(BS)
V = Vector{UInt8}.(BS)
print("V: "); display(V)
V2 = reduce(hcat,V)'[:,8-nD+1:8] .- 0x30
print("V2: "); display(V2)
V3 = Float32.(V2) .- 0.5
print("V3: "); display(V3)
V = (Float32.(reduce(hcat,Vector{UInt8}.(bitstring.(Int8.(0:2^nD-1))))'[:,8-nD+1:8] .- 0x30) .- 0.5f0)
end
The Noteworthy Differences from other Languages doc seems to suggest that enclosing the long expression in parentheses would allow a line to continue at a ‘.’:
Julia has no line continuation syntax: if, at the end of a line, the input so far is a complete expression, it is considered done; otherwise the input continues. One way to force an expression to continue is to wrap it in parentheses.
However, my attempts to break up this long line, even when enclosed in parentheses, have all resulted in error messages.