Created
June 7, 2011 08:07
-
-
Save draegtun/1011872 to your computer and use it in GitHub Desktop.
10 (8!) Io one liners to impress your friends
This file contains 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
#!/usr/bin/env io | |
# see: http://news.ycombinator.com/item?id=2610243 | |
# http://news.ycombinator.com/item?id=2612686 | |
doFile("x_load_me.io") | |
# 1 | |
1 to(10) map(*2) | |
# 2 | |
1 to(1000) asList sum | |
# 3 | |
tweet findSeqs( wordlist ) | |
# 4 | |
fileText := File with("data.txt") open readLines join | |
fileLines := File with("data.txt") open readLines | |
# 5 | |
4 repeat (i, writeln("Happy Birthday " .. if(i == 2, "dear NAME", "to you"))) | |
# 6 | |
list(49, 58, 76, 82, 88, 90) partition(x, x > 60) | |
# 7 | |
results := SGML URL with("http://search.twitter.com/search.atom?&q=io") fetch asXML | |
# 8 | |
list(14, 35, -7, 46, 98) min | |
list(14, 35, -7, 46, 98) max |
This file contains 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
#!/usr/bin/env io | |
Range | |
List partition := method ( | |
returnThis := Object clone do ( | |
passed := list() | |
failed := list() | |
) | |
argSlot := call message argAt(0) | |
cond := call message argAt(1) | |
self foreach (n, | |
newSlot(argSlot asString, n) | |
if (doMessage(cond), | |
returnThis passed append(n), | |
returnThis failed append(n)) | |
) | |
returnThis | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment