Skip to content

Instantly share code, notes, and snippets.

View vito's full-sized avatar

Alex Suraci vito

View GitHub Profile
load: "examples/html.atomo"
load: "examples/web.hs"
Demo = Website clone
Demo index :=
HTML new (do: {
doctype
html: {
head: {
@vito
vito / 0-before
Created September 6, 2010 15:23
Atomo's pretty printer
v match: (b: <self>) :=
if: b contents empty? then: { @no-match } else: { es = b contents;
[p, e] = es head targets;
match = (p as: Pattern) matches?: v;
if: (match == @no) then: { v match: (Block new: es tail in: b scope) } else: { @(yes: obj) = match;
obj join: (Block new: [e] in: b scope) } }
@vito
vito / Timer
Created September 6, 2010 02:38
Timer
$ atomo
> load: "prelude/units.atomo"
@ok
> p = Timer do: { "hi!" print } every: 5 seconds
<process 92>
> hi!
hi!
hi!
hi!
hi!
@vito
vito / associativity
Created September 5, 2010 21:47
associativity & precedence declarations
atomo $ atomo
> { 1 -> 2 * 3 }
{ (1 -> 2) * 3 }
> operator right ->
@ok
> { 1 -> 2 * 3 }
{ 1 -> (2 * 3) }
>
> { [a, @+] -> 0 } contents head targets head as: Pattern
<pattern [a, @+]>
> { [a, @+] -> 0 } contents head targets head (as: Pattern) matches?: [1, 2]
@no
> { [a, @+] -> 0 } contents head targets head (as: Pattern) matches?: [1, @+]
@(yes: <object>)
> @(yes: o) = { [a, @+] -> 0 } contents head targets head (as: Pattern) matches?: [1, @+]
@(yes: <object>)
> o a
1
atomo $ atomo examples/error.atomo
traceback:
"examples/error.atomo" (line 6, column 1)
{ a print } call
... internal ...
"examples/error.atomo" (line 6, column 3)
a print
"examples/error.atomo" (line 6, column 3)
a
"examples/error.atomo" (line 1, column 6)
alex@alex-laptop:~/the$ the
> [] includes?: _ := False
@defined
> (xs: List) includes?: y := if: (xs (take: y length) == y) then: { True } else: { xs tail includes?: y }
@defined
> [1, 2, 3, 4, 5] includes?: [2, 3]
True
> [1, 2, 3, 4, 5] includes?: [2, 4]
False
> "restaurant" includes?: "aura"
import Data.Int
import Data.Time.Clock.POSIX
import LLVM.Core
import LLVM.ExecutionEngine
import System.Environment
main :: IO ()
main = do
as <- getArgs
let num =
module A.AutoFlow where
import Data.Char (isSpace)
import Text.HTML.TagSoup
autoFlow :: String -> String
autoFlow = renderTags . autoFlow' False . canonicalizeTags . parseTags
where
autoFlow' open []
| open = [TagClose "p"]
#title:{The}
hello!
#bold:{Hello, there. #bold:{My name is Inigo Monyoya}.}
goodbye!
#interaction:({
1 + 1