Ticket #15 (closed enhancement: fixed)

Opened 11 months ago

Last modified 11 months ago

List/Table comprehensions

Reported by: JarrettBillingsley Assigned to: JarrettBillingsley
Priority: major Milestone: MiniD 2
Component: Language Keywords:
Cc:

Description

Python-esque list (and maybe table) comprehensions.

[x for x in 0 .. 10]
[[x, y] for x in 0 .. 4 for y in 0 .. 3]
{[name] = shortName for name in names for shortName in shortNames}

Change History

01/15/08 21:18:28 changed by JarrettBillingsley

  • component changed from component1 to Language.

01/17/08 12:38:52 changed by JarrettBillingsley

OK, they're implemented, but I had another idea -- Haskell-like parallel comprehensions (i.e. "zipping" comprehensions). I mean, they can be done by using a zip function, but these are just so damn cool, and useful especially for table comprehensions, i.e. turning two parallel arrays into a table:

{[name] = age for name in names && for age in ages}

One possible syntax..

The alternative is:

{[name] = age for _, name, age in izip(names, ages)}

Hm. Might not be worth it.

01/17/08 15:32:16 changed by JarrettBillingsley

  • status changed from new to closed.
  • resolution set to fixed.