List comprehension

8 views
Skip to first unread message

Maxime ANDRÉ

unread,
Oct 17, 2020, 12:37:51 PM10/17/20
to Curv

Hi,
I have a little problem : i want to make multiple copies of a shape, that are translated.
i simplified the code :
union [for (i in [1..3]) (box >> move [i*10, 0, 0])]
 it doesn't work (error message below)
but if I remove the multiplication :
union [for (i in [1..3]) (box >> move [10, 0, 0])]
It works but obviously the boxes are not translated.
I don't understand what is wrong.
Maxime André


here is the error message :

ERROR: assertion failed
at file "/usr/local/lib/curv/std.curv":
132|         assert (is_bbox3(shape.bbox));
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at file "/usr/local/lib/curv/std.curv":
879|     in make_shape {
            ^^^^^^^^^^^^
880|>        // TODO: dist[x,y,z,t] : shape.dist(...[x,y,z]-delta, t),
881|>        // TODO: dist p : shape.dist(...p[[X,Y,Z]]-delta, p[T]),
882|>        dist p : shape.dist(p[X]-delta[X], p[Y]-delta[Y], p[Z]-delta[Z], p[T]),
883|>        colour p : shape.colour(p[X]-delta[X],p[Y]-delta[Y],p[Z]-delta[Z],p[T]),
884|>        bbox : [shape.bbox[MIN]+delta, shape.bbox[MAX]+delta],
885|>        is_2d : shape.is_2d,
886|>        is_3d : shape.is_3d,
887|     };
     ^^^^^

Doug Moen

unread,
Oct 17, 2020, 2:03:41 PM10/17/20
to Curv
The error message is terrible. I will look into that.

If you start the Curv REPL, by typing 'curv' with no arguments, and type [1..3], you will see the problem.
   $ curv
   curv> [1..3]
   [[1,2,3]]
   curv> 1..3
   [1,2,3]

What you want to use instead is:
   union [for (i in 1..3) (box >> move [i*10, 0, 0])]
And you can type this expression into the REPL as well.

Doug Moen.
--
You received this message because you are subscribed to the Google Groups "Curv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to curv+uns...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages