Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
240 lines (217 sloc) 9.88 KB
{ UID: uid-f25a-08e1-7d7d-09f8
is: gui
title: "Cyrus Examples"
view:
{ is: style direction: vertical }
{ view: open item: uid-0233-cc56-1722-1a61 }
{ view: closed item: uid-26bc-8ee9-5443-851a }
{ view: closed item: uid-8ed3-ee4a-eeef-0313 }
{ view: closed item: uid-5eeb-9bff-d369-0520 }
{ view: closed item: uid-4b05-3181-d424-eaef }
{ view: closed item: uid-0112-09a9-3f54-b720 }
{ view: closed item: http://localhost:8081/uid-4dd7-7ef1-ecfa-1445.json }
{ view: closed item: uid-7356-dfcc-2173-4525 }
}
{ UID: uid-26bc-8ee9-5443-851a
Rules: uid-16f2-2db0-e9fe-1d7d
is: demo editable
title: Demo
x: Hello
y: World
}
{ UID: uid-16f2-2db0-e9fe-1d7d
is: demo rule editable
when: "run set title to join of x and y"
title: => join " " ( @x @y )
}
{ UID: uid-8ed3-ee4a-eeef-0313
Rules: uid-e85e-7755-1593-0665 uid-c287-63cf-9c45-1f9f uid-4709-6676-f0e2-8054
is: editable mars rover
title: Mars Rover
commands: L M R R M
coordinates: 0 0
orientation: 0 1
}
{ UID: uid-e85e-7755-1593-0665
is: editable mars rover rule
when: L command, turn left
commands: ( L => # ) **
orientation: => @. dot ( ( 0 -1 ) ( 1 0 ) )
}
{ UID: uid-c287-63cf-9c45-1f9f
is: editable mars rover rule
when: R command, turn right
commands: ( R => # ) **
orientation: => @. dot ( ( 0 1 ) ( -1 0 ) )
}
{ UID: uid-4709-6676-f0e2-8054
is: editable mars rover rule
when: M command, move forward
commands: ( M => # ) **
coordinates: => @. + @orientation
}
{ UID: uid-5eeb-9bff-d369-0520
Rules:
{ is: gui rule view: # => 9 .. 0 }
{ is: gui rule view: ( > 0 ) => ( @. bottles ) "of beer on the wall," ( @. bottles ) "of beer. Take one down, pass it around,"
(( @. - 1 ) bottles ) "of beer on the wall." }
{ is: gui rule view: 0 => "No more bottles of beer on the wall, no more bottles of beer."
"Go to the store, buy some more, 99 bottles of beer on the wall. " }
{ is: gui rule view: { **: 1 bottles => "1 bottle" }}
{ is: gui rule view: { **: 0 bottles => "no more bottles" }}
{ is: gui rule view: ( * * ) => join " " @. }
is: editable gui
title: "9 bottles"
}
{ UID: uid-4b05-3181-d424-eaef
Rules:
{ is: quicksort rule view: { **: qs ** => if ((count @.1) == 0) then # else ((qs (@.1:1.. filter (@.. < @.1:0))) @.1:0 (qs (@.1:1.. filter (@.. >= @.1:0)))) }}
{ is: quicksort rule view: { **: qs ** } !=> flatten @. }
is: editable quicksort
title: "Quicksort"
view: qs (5 9 2 8 3 1 1 6 3 21 3 5 8 98 75 4 33 2 4 5 8 9 0 4 3 2 7 11)
}
{ UID: uid-0112-09a9-3f54-b720
Rules: uid-5f5d-6d29-64d8-2d8c uid-b3ae-5b55-65ad-a296 uid-701d-7264-39b3-ad65 uid-5c83-67b4-2edf-1474
is: attendable event
title: "Geek Speak December"
text: "Europe's Top Tech"
start: "Wed 12 Dec 2012 18:00:00 GMT"
end: "Wed 12 Dec 2012 23:00:00 GMT"
list: uid-3e0e-a630-b669-23d7 uid-0a01-cec7-61b7-a770
}
{ UID: uid-3e0e-a630-b669-23d7
Rules: uid-f885-d373-af3a-cb8d uid-e006-8ce3-054a-8158 uid-c435-22f4-7938-6d4f uid-fbad-2ac9-f645-6c87
is: reviewable event
title: "My Love of Clojure"
text: "Long ago, I fell in love with Lisp.."
start: "Wed 12 Dec 2012 18:00:00 GMT"
end: "Wed 12 Dec 2012 19:00:00 GMT"
within: uid-0112-09a9-3f54-b720
review-template: {
email: { input: textfield label: "Your Email:" }
comments: { input: textfield label: "Comments:" }
pres-style: { input: rating label: "Presentation Style:" }
}
}
{ UID: uid-0a01-cec7-61b7-a770
Rules: uid-f885-d373-af3a-cb8d uid-e006-8ce3-054a-8158 uid-c435-22f4-7938-6d4f uid-fbad-2ac9-f645-6c87
is: reviewable event
title: "My Love of FORTRAN"
text: "Back when I were a lad .."
start: "Wed 12 Dec 2012 19:00:00 GMT"
end: "Wed 12 Dec 2012 20:00:00 GMT"
within: uid-0112-09a9-3f54-b720
review-template: {
email: { input: textfield label: "Your Email:" }
comments: { input: textfield label: "Comments:" }
pres-style: { input: rating label: "Presentation Style:" }
}
}
{ UID: uid-5f5d-6d29-64d8-2d8c
is: attendable event rule
when: "rsvp attending received ensure user is in attendees"
Alerted: { is: rsvp event: @ attending: yes }
attendees: => @. with @Alerted
}
{ UID: uid-b3ae-5b55-65ad-a296
is: attendable event rule
when: "rsvp not attending ensure user not in attendees"
attendees: { attending: no } => #
}
{ UID: uid-701d-7264-39b3-ad65
is: event rule
when: "reviews of sub-events change, calculate average rating"
list: { rating: number }
rating: => ( + @list:rating ) / ( count @list:rating )
}
{ UID: uid-5c83-67b4-2edf-1474
is: editable event rule
when: "anything changes, pick an email at random"
list: { contest-selection: * }
text: => join "\n" ( "Europe's Top Tech" "Contest winner:" ( @=list:contest-selection select ( random 0 ( ( count @=list ) - 1 ) ) ) )
}
{ UID: uid-f885-d373-af3a-cb8d
is: reviewable event rule
when: "rsvp review received ensure user is in reviews"
Alerted: { is: rsvp event: @ within: { attending: yes } }
reviews: => @. with @Alerted
}
{ UID: uid-e006-8ce3-054a-8158
is: reviewable event rule
when: "rsvp not attending ensure user not in reviews"
reviews: { within: { attending: no } } => #
}
{ UID: uid-c435-22f4-7938-6d4f
is: reviewable event rule
when: "review changes, calculate average rating"
reviews: { rating: number }
rating: => ( + @reviews:rating ) / ( count @reviews:rating )
}
{ UID: uid-fbad-2ac9-f645-6c87
is: editable event rule
when: "anything changes, pick an email at random"
reviews: { email: * }
contest-selection: => @=reviews:email select ( random 0 ( ( count @=reviews ) - 1 ) )
}
{ UID: uid-0233-cc56-1722-1a61
is: editable gui
title: "To do MVC"
todo: "actually save checkbox state"
"match form to a gui version"
"key-up on form not button"
"set focus on new todo text"
"fix single-element list"
"what does the back button mean?"
"mark form elements dirty rather than sending back the whole lot when not changed"
"not mentioned means keep same - add/del in list not idemp and needs 3+/3- index"
local: { }
Rules:
{ is: gui rule view: { todos: { style: # => { is: style direction: horizontal widths: 10% 80% 10% } } } }
{ is: gui rule Alerted: { is: form } form: # => @Alerted }
{ is: gui rule form: { is: form form: { todos: { } } }
view: { todos: { id: { value: @-form:form:todos:id }
done: { value: => @-form:form:todos:done }
text: { value: => @-form:form:todos:text } } } }
{ is: gui rule form: { is: form form: { todos: { del: pushed } } }
view: { todos: { id: { value: @-form:form:todos:id } } => # } }
{ is: gui rule form: { is: form form: { todos: { id: 0 text: not " " } } }
view: { todos: not { text: { value: @=form:form:todos:text } }
=> @. with { id: 123
done: { input: checkbox label: / }
text: { input: textfield value: @=form:form:todos:text }
del: { input: button label: X } } } }
view: {
todos: { id: { input: textfield value: 0 } done: { input: checkbox label: / } text: { input: textfield value: " " } del: { input: button label: X } }
{ id: { input: textfield value: 1 } done: { input: checkbox label: / } text: { input: textfield value: "get the news" } del: { input: button label: X } }
{ id: { input: textfield value: 2 } done: { input: checkbox label: / } text: { input: textfield value: "get the loaf" } del: { input: button label: X } }
}
}
{ UID: uid-7356-dfcc-2173-4525
is: editable gui
title: Calculator
local: { acc: 0 num: 0 op: + }
Rules:
{ is: gui rule view: { bt: { style: # => { is: style direction: horizontal } } } }
{ is: gui rule Alerted: { is: form } local: { key: => @Alerted:form:pushed } }
{ is: gui rule Alerted: { is: form } form: # => @Alerted }
{ is: gui rule form: { is: farm } local: { key: => @form:form:pushed } }
{ is: gui rule local: { key: /bt:k[0-9]/ num: => + (join (@. ({ bt:k0: 0 bt:k1: 1 bt:k2: 2 bt:k3: 3 bt:k4: 4 bt:k5: 5 bt:k6: 6 bt:k7: 7 bt:k8: 8 bt:k9: 9 } select @local:key))) } }
{ is: gui rule local: { key: bt:dp num: => if (not @. contains .) then (join (@. .)) else @. } }
{ is: gui rule local: { key: bt:cl num: => 0 }}
{ is: gui rule local: { key: /bt:pl|bt:mi|bt:ti|bt:di|bt:eq/ num: * acc: => @. @local:op @local:num } }
{ is: gui rule local: { key: /bt:pl|bt:mi|bt:ti|bt:di|bt:eq/ num: => # op: => { bt:pl: + bt:mi: - bt:ti: × bt:di: ÷ bt:eq: + } select @local:key } }
{ is: gui rule local: { key: bt:cs num: # acc: => @. × -1 } }
{ is: gui rule local: { key: bt:cs num: * => @. × -1 } }
{ is: gui rule local: { key: bt:ms mem: => if (@local:num set) then @local:num else @local:acc } }
{ is: gui rule local: { key: bt:mr num: => if (@local:mem set) then @local:mem else @. } }
{ is: gui rule local: { key: * => # } view: { result: { value: => if (@local:num set) then @local:num else @local:acc }}}
view: {
result: { input: textfield value: 0 }
bt:
{ k7: { input: button label: 7 } k8: { input: button label: 8 } k9: { input: button label: 9 } ti: { input: button label: × } cs: { input: button label: +/- } }
{ k4: { input: button label: 4 } k5: { input: button label: 5 } k6: { input: button label: 6 } di: { input: button label: ÷ } ms: { input: button label: MS } }
{ k1: { input: button label: 1 } k2: { input: button label: 2 } k3: { input: button label: 3 } pl: { input: button label: + } mr: { input: button label: MR } }
{ dp: { input: button label: . } k0: { input: button label: 0 } cl: { input: button label: C } mi: { input: button label: - } eq: { input: button label: = } }
}
}