Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#2816 closed defect (fixed)

Support threaded reductions language extension

Reported by: Martin Sjölund Owned by: Martin Sjölund
Priority: high Milestone: 1.9.1
Component: MetaModelica Version: trunk
Keywords: Cc: Per Östlund

Description

Support threaded reductions language extension:

function testThreadedReduction
  output list<Integer> l1 := list(a+b threaded for a in 1:2, b in 3:4); // {1+3,2+4}
  output list<Integer> l2 := list(a+b for a in 1:2, b in 3:4); // {4,5,5,6}
end testThreadedReduction;

Change History (3)

comment:1 by Martin Sjölund, 10 years ago

Status: newassigned

comment:2 by Martin Sjölund, 10 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r22279.

comment:3 by Henning Kiel, 7 years ago

Can this be implemented for for-loops as well?

threaded for a in list1, b in list2 loop
  sum := sum + a*b;
end for;

Would be syntactic sugar for

rest := list2;
for a in list1 loop
  b::rest := rest;
  sum := sum + a*b;
end for;
if not listEmpty(rest) fail();

and would avoid temporary list creation as in

tmp := list(a*b threaded for a in list1, b in list2);
for t in tmp loop
  sum := sum + t;
end for;
Note: See TracTickets for help on using tickets.