yimingchen 3 days ago | flag | on: Typo in the document of `for` loop

The comment in the code


table Ranges = with 
  [| date(2010, 01, 03) as Start, date(2010, 10, 12) as End |]
  [| date(2011, 07, 23)         , date(2012, 03, 01)        |]
  [| date(2010, 09, 27)         , date(2011, 05, 31)        |]
 
Ranges.Collision = for Start in Ranges.Start, 
                       End   in Ranges.End
 
  // (true, false, false) on the 1st iteration,
  // (false, true, false) on the 2nd,
  // (false, false, true) on the 3rd  
  Ranges.NotSameRange = (Start != Ranges.Start or End != Ranges.End)
 
  // (true, false, true)  on the 1st iteration,
  // (false, true, false) on the 2nd iteration, 
  // (true, false, true)  on the 3rd iteration
  Ranges.Intersects = max(Start, Ranges.Start) <= min(End, Ranges.End)
 
  // true  on the 1st iteration,
  // false on the 2nd iteration,
  // true  on the 3rd iteration
  return any(Ranges.NotSameRange and Ranges.Intersects)
 
show table "Ranges" with
  Ranges.Start
  Ranges.End 
  Ranges.Collision // (true, false, true)

should be


  // (false, true, true) on the 1st iteration,
  // (true, false, true) on the 2nd,
  // (true, true, false) on the 3rd  
  Ranges.NotSameRange = (Start != Ranges.Start or End != Ranges.End)

yimingchen 4 days ago | flag | on: Unable to compile the example

table Sizes[size] = with 
  [| as size, as Weight |]
  [| "S",     0.5       |]
  [| "M",     0.75      |]
  [| "L",     1         |]
  [| "XL",    0.75      |]
 
table Colors[color] = with 
  [| as color, as Weight |]
  [| "white",  1         |]
  [| "red",    2         |]
  [| "green",  0.5       |]
  [| "blue",   0.75      |]
  [| "black",  1         |]
 
table Catalog = with 
  [| as Size, as Color, as AltColor, as Price |]
  [| "S",     "red",    "blue",      9.99     |]
  [| "M",     "blue",   "white",     10.99    |]
  [| "XL",    "black",  "green",     15.49    |]
 
expect Catalog.size = Catalog.Size
expect Catalog.color = Catalog.Color
 
table Variant = cross(Sizes, Colors)
Variant.W = Sizes.Weight * Colors.Weight 
 
// When both dimensions are provided (by name), behaves as a normal lookup.
WhiteLarge = Variant.Weight[size: "L", color: "white"]
Catalog.Alt = Variant.W[size: Catalog.size, color: Catalog.AltColor]
 
// If a single dimension is provided by name, behavior depends on whether key
// is a scalar or not. 
 
// If scalar, the result is a vector in the other table of the cross-table: 
Colors.Small = Variant.W[size: "S"]
Sizes.Blue = Variant.W[color: "blue"]
 
// If non-scalar, the lookup will automatically look for the other 
// dimension in the key's table. 
Catalog.Alt = Variant.W[color: Catalog.AltColor] // implicit 'size: Catalog.size'
 
// Note that if no label is provided, the rightmost dimension is assumed: 
Catalog.Alt = Variant.W[Catalog.AltColor] // same as the abvoe

Error message:
Error on line 17, column 18: Catalog.Color can only be assigned a value with dimension Color.

See https://try.lokad.com/34mkamdruk1ra

yimingchen 5 days ago | flag | on: Another Typo

Samely, the table in the section Filtered Aggregation

Pid Sold
apple 10
orange -3
banana -2

should have been

Pid Sold
apple 3
orange -2
banana -3


table Orders = with
  [| as Pid, as OrderDate, as Quantity |]
  [| "apple",  date(2020, 4, 15), 3 |]
  [| "apple",  date(2020, 4, 16), 7 |]
  [| "orange", date(2020, 4, 16), 2 |]
 
table Products = with
  [| as Pid, as MyDefault |]
  [| "apple",  -1 |]
  [| "orange", -2 |]
  [| "banana", -3 |]

Products.Sold = sum(Orders.Quantity)
  when (Orders.OrderDate < date(2020, 4, 16))
  default Products.MyDefault
  by Orders.Pid
  at Products.Pid
 
show table "Products" with
  Products.Pid
  Products.Sold

yimingchen 5 days ago | flag | on: Typo in the section `Empty Group`

The following code in the section Empty Group is supposed to be

| Pid | Sold |
| :-------: | :---: |
| apple | 10 |
| orange | 2 |
| banana | -3 |

instead of

| Pid | Sold |
| :-------: | :---: |
| apple | 10 |
| orange | 2 |
| banana | -2 |


table Orders = with
  [| as Pid, as OrderDate, as Quantity |]
  [| "apple",  date(2020, 4, 15), 3 |]
  [| "apple",  date(2020, 4, 16), 7 |]
  [| "orange", date(2020, 4, 16), 2 |]
 
table Products = with
  [| as Pid, as MyDefault |]
  [| "apple",  -1 |]
  [| "orange", -2 |]
  [| "banana", -3 |]
 
Products.Sold = sum(Orders.Quantity)
  default Products.MyDefault
  by Orders.Pid
  at Products.Pid
 
show table "Products" with
  Products.Pid
  Products.Sold