From: Mike D. Lowis Date: Thu, 15 Mar 2012 18:55:53 +0000 (-0400) Subject: Added datatype examples to language spec X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=9aaf13b457530205d392d7e2c979d23a73826ffe;p=archive%2Fdlang.git Added datatype examples to language spec --- diff --git a/LANGUAGE.markdown b/LANGUAGE.markdown index cdcd49b..ef21bb8 100644 --- a/LANGUAGE.markdown +++ b/LANGUAGE.markdown @@ -37,6 +37,7 @@ Here are some examples for defining numbers: #### Characters 'A' + '\x00' #### Symbols @@ -64,13 +65,50 @@ Here are some examples for defining numbers: ['a', 1] # A vector with two elements of different types #### Maps + + # A Map with homogeneous keys + { + "foo": "bar", + "bar": "foo" + } + + # A Map with hetergeneous keys + { + $foo: 1.5, + "bar": 5.1 + } + #### Strings + "This is a string\n" + ### Blocks #### Definition and Usage + + add2 = {|a| + a + 2 # Adds 2 to the argument and returns the result + } + + add2(5) # Returns 7 + +Anonymous functions and immediate execution + + ({|a| a + 2})(5) # Returns 7 + #### Lexical Scoping + + create_adder = {|a| + # Creates and returns a new function that adds a to the value passed + # into the new function + {|b| a + b } + } + + (create_adder(2))(5) # Returns 7 + #### Performance and Behavior +A Work In Progress + ### Streams A Work In Progress