Diff
Not logged in

Differences From Artifact [adcd1590f6f5bc80]:

To Artifact [d36ee595e22be49c]:


113 def f(x) { if(x==0){1}else{x*f(x-1)} } in f(10) #=> 3628800 113 def f(x) { if(x==0){1}else{x*f(x-1)} } in f(10) #=> 3628800 114 yet still the code below also works 114 yet still the code below also works 115 def x=21 in def x=x+x in x #=> 42. 115 def x=21 in def x=x+x in x #=> 42. 116 The internal scoping mechanism is a little tricky (this is for coping with 116 The internal scoping mechanism is a little tricky (this is for coping with 117 the "layer" feature explained below), but I hope that it works as everyone 117 the "layer" feature explained below), but I hope that it works as everyone 118 expects in most cases, as long as you don't use the same-name-variables heavil 118 expects in most cases, as long as you don't use the same-name-variables heavil 119 119 > 120 (Experimental) pattern matching is also available. Here is an example. > 121 > 122 def adjSum(lst) > 123 { > 124 case( lst ) > 125 when( {car:x, cdr:{car: y, cdr:z}} ) { {car: x+y, cdr: adjSum(z)} } > 126 when( {car:x, cdr:{}} ) { {car: x, cdr: {}} } > 127 when( {} ) { {} } > 128 }; > 129 > 130 It is expanded to a sequence of if-then-elses prefering the first-match. > 131 Note that {a: _} pattern matches all the tables that have the .a field. > 132 It also matches to {a: 123, b: 456} having extra .b field. So, changing the > 133 order of "when"s in the above code changes the behavior. > 134 > 135 120 136 121 137 122 <<Basic Features>> 138 <<Basic Features>> 123 139 124 Polemy is an untyped functional programming language that has 140 Polemy is an untyped functional programming language that has 125 - integers: 0, 123, 456666666666666666666666666666666666666789, ... 141 - integers: 0, 123, 456666666666666666666666666666666666666789, ... 126 - strings: "hello, world!\n", ... 142 - strings: "hello, world!\n", ... ................................................................................................................................................................................ 143 159 144 Here you can see that @LayerName( Expression ) executes the inner Expression i 160 Here you can see that @LayerName( Expression ) executes the inner Expression i 145 the @LayerName layer. Other than @value, one other predefined layer exists: @m 161 the @LayerName layer. Other than @value, one other predefined layer exists: @m 146 162 147 >> @macro( 1+2 ) 163 >> @macro( 1+2 ) 148 {pos@value:{lineno@value:3, column@value:9, filename@value:<REPL>}, 164 {pos@value:{lineno@value:3, column@value:9, filename@value:<REPL>}, 149 is@value:app, 165 is@value:app, 150 arg@value:{car@value:{pos@value:{lineno@value:3, column@value:9, filename@v | 166 args@value:{car@value:{pos@value:{lineno@value:3, column@value:9, filename@v 151 is@value:int, 167 is@value:int, 152 data@value:1}, 168 data@value:1}, 153 cdr@value:{ 169 cdr@value:{ 154 car@value:{pos@value:{lineno@value:3, column@value:11, filenam 170 car@value:{pos@value:{lineno@value:3, column@value:11, filenam 155 is@value:int, 171 is@value:int, 156 data@value:2}, 172 data@value:2}, 157 cdr@value:{}}}, 173 cdr@value:{}}}, ................................................................................................................................................................................ 351 pow(@macro(x),10) 367 pow(@macro(x),10) 352 ) 368 ) 353 }; 369 }; 354 370 355 Here, x is a syntax tree but n is an actual integer. If you read carefully, 371 Here, x is a syntax tree but n is an actual integer. If you read carefully, 356 you should get what is going on. Basically, @macro can be considered like 372 you should get what is going on. Basically, @macro can be considered like 357 quasiquoting and @value to be an escape from it. 373 quasiquoting and @value to be an escape from it. > 374 > 375 > 376 > 377 <<Primitives>> > 378 > 379 {} 0-ary create-empty-table > 380 . 2-ary table-get > 381 .? 2-ary table-has? > 382 .= 3-ary table-set > 383 > 384 if 3-ary if-then-else > 385 > 386 + - * / % || && 2-ary integer-operations (no short-circuit!) > 387 < > <= >= == != 2-ary generic comparison > 388 > 389 print 1-ary print-to-stdout > 390 > 391 _isint _isstr _isfun _isundefined _istable 1-ary dynamic-type-test > 392