You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This unrolls the loop in the AST to a vec4, replacing j with numbers 0, 1, 2, 3.
The reason there are no {} brackets is because the loop does not work under composition. Neither can you use continue or break.
It is different from the other loop that do inference but are restricted by items only when indexing. For example, a[i] can be used with the other loops, but not a[(i+1)%3]. The latter works fine with a vec4 un-loop.
s(vec4, f64) for looking up scalar in vector
This is useful in combination with the vec4 un-loop.
vec3 and vec2 un-loops
The vec3 and vec2 un-loops sets the rest of the components to 0:
println(vec3 i i+1)// prints `(1, 2, 3)`
println(vec2 i i+1)// prints `(1, 2)`
Examples
Random values:
vec4 _ random()
Convert array of length 3 into a vec4:
p := [1,2,3]
println(vec4 i if i == 3{0}else{ p[i]})// prints `(1, 2, 3, 0)`
Multiply two 4x4 matrices (row major):
multiply_matrix_matrix(a:[vec4], b:[vec4]) =
sift i { vec4 j a[i]*.vec4 k s(b[k], j)}
Swizzle to (z, x, y, w):
a := (x, y, z, w)
println(vec4 i s(a,if i == 3{ i }else{(i+1)%3}))// prints `(z, x, y, w)`
Motivation
This is designed for:
Flexible initialization of vec4 values
Reduce typing
Reduce bugs
Improve readability
The text was updated successfully, but these errors were encountered:
See PistonDevelopers#201
- Found a possible bug in “infer_len.rs” that needs closer investigation
- Added `ast::Vec4UnLoop`
- Added `ast::replace` module
- Added `lifetime::Kind::is_decl_un_loop`
When you need this:
In Dyon you can just type:
This unrolls the loop in the AST to a vec4, replacing
j
with numbers0, 1, 2, 3
.The reason there are no
{}
brackets is because the loop does not work under composition. Neither can you usecontinue
orbreak
.It is different from the other loop that do inference but are restricted by items only when indexing. For example,
a[i]
can be used with the other loops, but nota[(i+1)%3]
. The latter works fine with avec4
un-loop.s(vec4, f64)
for looking up scalar in vectorThis is useful in combination with the
vec4
un-loop.vec3
andvec2
un-loopsThe
vec3
andvec2
un-loops sets the rest of the components to 0:Examples
Random values:
Convert array of length 3 into a
vec4
:Multiply two 4x4 matrices (row major):
Swizzle to
(z, x, y, w)
:Motivation
This is designed for:
vec4
valuesThe text was updated successfully, but these errors were encountered: