Skip to content

Instantly share code, notes, and snippets.

@dahlia
Created June 7, 2010 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dahlia/428318 to your computer and use it in GitHub Desktop.
Save dahlia/428318 to your computer and use it in GitHub Desktop.
Veeyu snippets

List comprehension

Map

The following code generates times-table:

times-table := [x * y, x: 2 ~ 9, y: 1 ~ 9]

The code is equivalent to:

times_table = [x * y for x in xrange(2, 10) for y in xrange(1, 10)]

in Python.

2 ~ 9 makes a <range> from 2 to 9. It is equivalent to <range>(min: 2, max: 9).

Filter

The following code generates a list of odd numbers from 1 to 100:

odds := [x, x: 1 ~ 100, x isa? <odd-number>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment