retroforth/example/CloseParen.retro
crc 2e95ec501a update more examples to use new word names
FossilOrigin-Name: 708314f58b4253b273c217a11265725bad4c8d7d7c53c503510440dade50be4d
2020-07-06 02:49:49 +00:00

35 lines
818 B
Text

I find `)` useful to punctuate code chunks.
~~~
:) ; immediate (code_chunk_punctuation_that_does_nothing
~~~
Here is an example:
:i@ (an-n) a:fetch ;
~~~
{{
:I@ (an-n) I a:fetch ;
'Index 'Value [ var ] bi@
:lt?-or-gt? hook ;
:pre.min (a-an)
(comparison &lt? &lt?-or-gt? set-hook )
(begin_with #-1 !Index n:MAX !Value dup a:length ) ;
:pre.max (a-an)
(comparison &gt? &lt?-or-gt? set-hook )
(begin_with #-1 !Index n:MIN !Value dup a:length ) ;
:min-or-max (a-nn) [ dup I@ dup @Value lt?-or-gt?
[ !Value I !Index ] [ drop ] choose ] indexed-times
(a-nn drop @Index @Value ) ;
---reveal---
:a:min (a-iv) pre.min min-or-max ;
:a:max (a-iv) pre.max min-or-max ;
}}
~~~
```
{ #3 #2 #5 #7 #3 } a:min dump-stack nl reset
{ #3 #2 #5 #7 #3 } a:max dump-stack nl
```