Created
July 23, 2013 15:48
-
-
Save randyzwitch/6063486 to your computer and use it in GitHub Desktop.
Python, Julia, R functional programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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