Created
December 4, 2011 06:15
-
-
Save sriki77/1429386 to your computer and use it in GitHub Desktop.
Io Day 3
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 | |
OperatorTable addAssignOperator(":", "genAttribute") | |
Builder := Object clone | |
Builder genAttribute := method(k,v, | |
k = k asMutable removePrefix("\"") removeSuffix("\"") | |
write(" "..(k)..("=\"")..(v).."\"") ) | |
Builder curlyBrackets := method( | |
call message arguments foreach(v,doString(v asString));self) | |
Builder forward := method( | |
write("<",call message name) | |
args := call message arguments | |
if(args at(0) asString beginsWithSeq("curlyBrackets"), self doMessage(args removeFirst)) | |
writeln(">") | |
args foreach( | |
arg, | |
content := self doMessage(arg); | |
if(content type == "Sequence",writeln(content)) | |
) | |
writeln("</",call message name,">") | |
) | |
Builder ul( | |
li({"author": "Tate","style":"bold"},"Io"), | |
li({"x":"y"},"lua"), | |
li("JavaScript") | |
) |
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 | |
squareBrackets := method( | |
l := List clone | |
call message arguments foreach(v,l append(doMessage(v))) | |
l | |
) | |
[1,2,3,4] println | |
[1,2,["a","b","c"],3,4] println |
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 | |
Builder := Object clone | |
Builder indent := -1 | |
Builder indentOutput := method( | |
for(i,1,indent, " " print) | |
) | |
Builder writeln := method(indentOutput;resend) | |
Builder forward := method( | |
indent = indent+1 | |
self writeln("<",call message name,">") | |
call message arguments foreach( | |
arg, | |
content := self doMessage(arg); | |
if(content type == "Sequence",self writeln(content)) | |
) | |
self writeln("</",call message name,">") | |
indent = indent-1 | |
) | |
Builder ul( | |
li("Io"), | |
li("lua"), | |
li("JavaScript"), | |
ul( li(Ruby("First of the seven languages")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment