Skip to content

Instantly share code, notes, and snippets.

@daniellansun
Created November 7, 2020 16:10
Show Gist options
  • Select an option

  • Save daniellansun/9d0235a84f28f2c396b4c12cb78304c0 to your computer and use it in GitHub Desktop.

Select an option

Save daniellansun/9d0235a84f28f2c396b4c12cb78304c0 to your computer and use it in GitHub Desktop.
Generate Multiplication Table with GINQ
GQ {
from v in (
from a in 1..9
innerjoin b in 1..9 on a <= b
select a as f, b as s, "$a * $b = ${a * b}".toString() as r
)
groupby v.s
select max(v.f == 1 ? v.r : '') as v1,
max(v.f == 2 ? v.r : '') as v2,
max(v.f == 3 ? v.r : '') as v3,
max(v.f == 4 ? v.r : '') as v4,
max(v.f == 5 ? v.r : '') as v5,
max(v.f == 6 ? v.r : '') as v6,
max(v.f == 7 ? v.r : '') as v7,
max(v.f == 8 ? v.r : '') as v8,
max(v.f == 9 ? v.r : '') as v9
}
@kayr
Copy link
Copy Markdown

kayr commented Nov 9, 2020

That does it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment