123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- but the {} pairs must match.
- }
- p 1
- p 2
- p 378
- p +108
- p -878
- p "Hello world\"
- "
- p `
- "Pop" goes the
- weasel's tail.
- `
- # There are built in identifiers for type Bool or nil
- p !true !false !nil
- # Museli has simple floating point constants, but no exponential notation,
- # of type Float
- p +0.5
- p -7.000005
- # Lists can be created between [ ] and may be heterogenous or homogenous.
- # The [ ] must be space separated.
- # The type is Any[] if the list is heterogenous.
- p [ foo "bar" ]
- # The type is Int[] below
- p [ 1 2 3 ]
- # A sequence of a lower case letter followed by anything that is not whitespace.
- # For example: this-IS*a/single+Word._
- # The value of a word is a string with the word itself.
- # If the word is at the beginning of the line it is invoked as a command.
- # Muesli's basic syntax is that of the command chain. Spaces separate the
- print "hello" world 7 0.9
- print ( mul 3 ( sum 5 7 ) )
- command {
- print "first block"
- } and also {
- print "second block"
- }
- type Door Object name String locked Bool keys Int[]
- set door1 (new Door "red door" true [])
- to openDoor [door Door key Item] Bool {
- if (contains (member door key) key) {
- set (member door open) true
- }
- }
- to Door open [key Item] Bool {
- if (contains (member door key) key) {
- set (member door open) true
- }
- }
- cover open openDoor[door Door key Item]
- set a 10
- print (get a 10)
- upset a 10
- =a 10
- print $a
- =indirect a
- = ($indirect) 20
- =$indirect 20
- print $a
- print $$indirect
- if (less a 10) {
- print "Less"
- } else {
- print "More"
- }
- 5
- =foo ( sqrt 2.0 + 3.14 - 2.1 )
- $foo
- of $door1 name # "red door"
- make $door1 name "green door"
- invoke $door1 open $key
- door1's name # same as (of $door1 name)
- door1's name "green door" # same as (make $door1 name "green door")
- door1, open $key1 # same as invoke $door1 open $key1, open must be a
- to openDoor list door Door key Item done Bool do
- if as contains as of a door key so a key so do
- make a door open true
- end
- end
|