Skip to content

Instantly share code, notes, and snippets.

@randyzwitch
Created July 23, 2013 15:48
Show Gist options
  • Save randyzwitch/6063486 to your computer and use it in GitHub Desktop.
Save randyzwitch/6063486 to your computer and use it in GitHub Desktop.
Python, Julia, R functional programming
#Cube every number from 1 to 100
#Python map function
cubes = map(lambda(x): x*x*x, range(1,100))
#Python list comprehension
cubes= [x*x*x for x in range(1,100)]
#R sapply function
cubes <- sapply(seq(1,100), function(x) x*x*x)
#Julia map function
cubes = map((x)-> x*x*x, [1:100])
#Julia list comprehension
cubes = [x*x*x for x in [1:100]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment