peter <pete…@tin.it> writes:
>Here is a version that corrects this.
>
>over 0 >= if
> swap over 1024 swap - min swap else \ limit positive n
> dup 0<= if nip 0 swap else \ limit negative n when e negative
> 1 over - rot max swap then then \ limit negative n
Can this be simplified? Here's what I came up with:
over 0 >= if
1024 2 pick - rot min
else
dup 0<= if
nip 0
else
1 over - rot max
then
then
swap
Or, using CASE with ?OF:
case
dup 0 >= ?of 1024 2 pick - rot min endof
dup 0<= ?of nip 0 endof
1 over - rot max
0 endcase
swap
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2026 CFP: http://www.euroforth.org/ef26/cfp.html