diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-13 10:03:26 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-13 10:03:26 -0700 |
commit | 5497090aa1e708c22cd240913a53dda32bb067aa (patch) | |
tree | 5a9eb76d447736a8199230c9386bd0a374b325dd /Readme.md | |
parent | 01caf342d072115c27926b1a61c2fc75ab9fbee0 (diff) | |
download | mu-5497090aa1e708c22cd240913a53dda32bb067aa.tar.gz |
1363 - rename 'integer' to 'number'
..now that we support non-integers.
Diffstat (limited to 'Readme.md')
-rw-r--r-- | Readme.md | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/Readme.md b/Readme.md index ad5510a4..9f59b35e 100644 --- a/Readme.md +++ b/Readme.md @@ -71,18 +71,18 @@ As a sneak peek, here's how you compute factorial in Mu: ```python recipe factorial [ default-space:address:array:location <- new location:type, 30:literal - n:integer <- next-ingredient + n:number <- next-ingredient { # if n=0 return 1 - zero?:boolean <- equal n:integer, 0:literal + zero?:boolean <- equal n:number, 0:literal break-unless zero?:boolean reply 1:literal } # return n * factorial(n - 1) - x:integer <- subtract n:integer, 1:literal - subresult:integer <- factorial x:integer - result:integer <- multiply subresult:integer, n:integer - reply result:integer + x:number <- subtract n:number, 1:literal + subresult:number <- factorial x:number + result:number <- multiply subresult:number, n:number + reply result:number ] ``` @@ -99,15 +99,15 @@ number of them. In particular you can have any number of results. For example, you can perform integer division as follows: ```python - quotient:integer, remainder:integer <- divide-with-remainder 11:literal, 3:literal + quotient:number, remainder:number <- divide-with-remainder 11:literal, 3:literal ``` Each reagent provides its name as well as its type separated by a colon. Types can be multiple words, like: ```python - x:array:integer:3 # x is an array of 3 integers - y:list:integer # y is a list of integers + x:array:number:3 # x is an array of 3 integers + y:list:number # y is a list of integers ``` Try out the factorial program now: @@ -124,13 +124,13 @@ its address. Mu maps names to addresses for you like in other languages, but in a more transparent, lightweight, hackable manner. This instruction: ```python - z:integer <- add x:integer, y:integer + z:number <- add x:number, y:number ``` might turn into this: ```python - 3:integer <- add 1:integer, 2:integer + 3:number <- add 1:number, 2:number ``` You shouldn't rely on the specific address Mu chooses for a variable, but it @@ -171,7 +171,7 @@ Once you've chained spaces together, you can access variables in them by adding a 'space' property: ```python - 3:integer/space:1 + 3:number/space:1 ``` This reagent is the integer in slot 3 of the space chained in slot 0 of the @@ -189,9 +189,9 @@ You can append arbitrary properties to reagents besides types and spaces. Just separate them with slashes. ```python - x:array:integer:3/uninitialized + x:array:number:3/uninitialized y:string/tainted:yes - z:list:integer/assign-once:true/assigned:false + z:list:number/assign-once:true/assigned:false ``` Most properties are meaningless to Mu, and it'll silently skip them when @@ -222,7 +222,7 @@ inserting code at them. ```python recipe factorial [ default-space:address:array:location <- new location:type, 30:literal - n:integer <- next-ingredient + n:number <- next-ingredient { +base-case: } @@ -231,17 +231,17 @@ inserting code at them. after +base-case [ # if n=0 return 1 - zero?:boolean <- equal n:integer, 0:literal + zero?:boolean <- equal n:number, 0:literal break-unless zero?:boolean reply 1:literal ] after +recursive-case [ # return n * factorial(n-1) - x:integer <- subtract n:integer, 1:literal - subresult:integer <- factorial x:integer - result:integer <- multiply subresult:integer, n:integer - reply result:integer + x:number <- subtract n:number, 1:literal + subresult:number <- factorial x:number + result:number <- multiply subresult:number, n:number + reply result:number ] ``` |