Add simpler branching functions such as 'if' and 'for'

Bug #1790116 reported by Xavier Hardy
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
YAQL
New
Undecided
Unassigned

Bug Description

I know 'switch' and 'select' allow to imitate the way 'if' and 'for' work but it would be nice (especially for beginners) to add a 'if' and 'for' functions. They could work like conditional assignment or list comprehension in Python.

yaql> if($.value = 42, then=>$.value/2, else=>$.value*2
21

yaql> if($.value = 42, $.value/2, $.value*2)
21

yaql> for($.i + $.value, i=>[1, 2, 3])
[43, 44, 45]

yaql> for(i=>[1, 2, 3], do=>$.i + $.value + 2)
[45, 46, 47]

yaql> for(i=>[1, 2, 3], j=>[100, 1000, 10000] do=>$.i + $.j + $.value + 2)
[145, 1046, 10047]

We have already implemented them and we would be happy to contribute.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.