Skip to content

Instantly share code, notes, and snippets.

@vito
Created August 10, 2010 22:29
Show Gist options
  • Save vito/518132 to your computer and use it in GitHub Desktop.
Save vito/518132 to your computer and use it in GitHub Desktop.
#title:{The}
hello!
#bold:{Hello, there. #bold:{My name is Inigo Monyoya}.}
goodbye!
#interaction:({
1 + 1
6 * 7
5.0 / 2.0
})
#interaction:({
a = 1
a
})
hello!
<string>Hello, there. <string>My name is Inigo Monyoya</strong>.</strong>
goodbye!
<pre>&gt; (1 + 1)
2
&gt; (6 * 7)
42
&gt; (5.0 / 2.0)
2.5
</pre>
<pre>&gt; <top> a = 1
&gt; a
1
</pre>
A = Object clone
(a: A) bold: (e: Expression) :=
a bold: e evaluate (as: String)
A bold: (s: String) :=
"<string>" .. s .. "</strong>"
A interaction: (e: Expression) := {
-- pseudo environment for evaluating the expressions
env = Object clone
log = e evaluate contents (map: { e |
if: ((e type == @define) || (e type == @set))
then: {
env do: (Block new: [e]) evaluate
"&gt; " .. (e as: String) .. "\n"
}
else: {
res = env join: (Block new: [e]) evaluate
"&gt; " .. (e as: String) .. "\n" .. (res as: String) .. "\n"
}
}) concat
"<pre>" .. log .. "</pre>"
} call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment