Is the use of
[ i in SOMETHING ] statement;
truly a list comprehension in say the Python sense or does it have
limitations. Fortran's implied DO loop is a list comprehension in an
extremely limited sense and then, only within READ/WRITE statements.
[ i in iterable-expression ] statement
is syntactic sugar for a forall loop. It’s the same as writing:
forall i in iterable-expression do statement
You can use a forall loop to fill in an array, like this: (A and B are
identical in this case)
var A = [ i in 1..10 ] i;
var B = forall j in 1..10 do j;
writeln(typeToString(A.type), " : ", A);
writeln(typeToString(B.type), " : ", B);
However, a forall expression on its own does not create an array. So, something
like this is not legal:
([ i in 1..10 ] i).size
Sections 25.1 and 25.2 in the spec talk about foralls, if you would like to
read more.
I’m not sure if list/array comprehensions have been discussed before. I’ll let
other developers chime in here.
Hope that helps!
Thomas Van Doren
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users