Created
November 29, 2011 20:42
-
-
Save devnoo/1406408 to your computer and use it in GitHub Desktop.
Seven languages in seven weeks :day 3 io
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
squareBrackets := method( | |
r := List clone; | |
call message arguments foreach(arg, | |
r append(arg) | |
) | |
) | |
languages := [ | |
"Io", | |
"Ruby", | |
"Java" | |
]; | |
languages println(); |
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
squareBrackets := method( | |
call message arguments | |
) | |
languages := [ | |
"Io", | |
"Ruby", | |
"Java" | |
]; | |
languages println(); |
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
Builder := Object clone | |
Builder indentLevel := 0 | |
Builder forward := method( | |
writeln(indentBy(indentLevel), "<", call message name, ">"); | |
indentLevel = indentLevel + 1; | |
call message arguments foreach( | |
arg, | |
content := self doMessage(arg); | |
if(content type == "Sequence", writeln(indentBy(indentLevel), content)) | |
) | |
indentLevel = indentLevel -1; | |
writeln(indentBy(indentLevel), "</", call message name, ">"); | |
) | |
Builder indentBy := method(indent, | |
" " repeated(indent) | |
) | |
Builder ul( | |
li("Io"), | |
li("Lua"), | |
li("JavaScript")) |
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
OperatorTable addAssignOperator(":" , "atPutAttribute") | |
Map atPutAttribute := method( | |
self atPut(call evalArgAt(0) asMutable removePrefix("\"") removeSuffix("\""), call evalArgAt(1)) | |
) | |
curlyBrackets := method( | |
map1 := Map clone | |
call message arguments foreach(arg, | |
map1 doMessage(arg) | |
) | |
) | |
Builder := Object clone | |
Builder indentLevel := 0 | |
Builder forward := method( | |
args := call message arguments | |
write(indentBy(indentLevel), "<", call message name); | |
if (args first name == "curlyBrackets", write(doMessage(args first) map(attr,val, | |
" " .. attr .. "=" .. "\"" .. val .. "\"" | |
) join); | |
args = args rest); | |
writeln(">"); | |
indentLevel = indentLevel + 1; | |
args foreach( | |
arg, | |
content := self doMessage(arg); | |
if(content type == "Sequence", writeln(indentBy(indentLevel), content)); | |
) | |
indentLevel = indentLevel -1; | |
writeln(indentBy(indentLevel), "</", call message name, ">"); | |
) | |
Builder indentBy := method(indent, | |
" " repeated(indent) | |
) | |
script := "Builder ul({\"class\" : \"navigation\"}, li(\"Io\"), li({\"class\":\"selected\"}, a({\"title\":\"JavaScript\",\"href\":\"http://www.denoo.info\"},\"bla\")))" | |
doString(script) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment