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
order after yield gives 'unbound variable or constructor' error.
For example:
val emps = [
{id = 100, name = "Fred", deptno = 10},
{id = 101, name = "Velma", deptno = 20},
{id = 102, name = "Shaggy", deptno = 30},
{id = 103, name = "Scooby", deptno = 30}];
from e in emps
yield {e.name, e.deptno}
order deptno
unbound variable or constructor: e
The text was updated successfully, but these errors were encountered:
In this fix, we also clarify the type of from with various clauses.
yield with record returns a record, even if that record has 1 field:
- from i in [1, 2, 3]
= yield {i};
val it = [{i=1},{i=2},{i=3}] : {i:int} list
yield can also have a scalar value:
from i in [1,2,3]
yield i mod 3;
val it = [1,2,0] : int list
But if the yield is in the middle of a pipeline, the scalar form is pretty useless; you need a field name in order to be table to use it in the next clause, so use a single-field record:
- from i in [1,2,3]
= yield {j = i mod 3}
= order j;
val it = [{j=0},{j=1},{j=2}] : {j:int} list
You can add another yield to convert it back to a scalar:
- from i in [1,2,3]
= yield {j = i mod 3}
= order j
= yield j;
val it = [0,1,2] : int list
order
afteryield
gives 'unbound variable or constructor' error.For example:
The text was updated successfully, but these errors were encountered: