Re: [stack] sweetening concatenative syntax
John Nowak <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Mar 18, 2008, at 10:17 PM, Manfred Von Thun wrote:
> quad turns [C:num, B:num, A:num | R] into [[P:num,N:num] list | R] :-
> Diff is B*B -$*A*C,
> ( Diff < 0.0,
> -> write(‘quadratic: cannot take root of negative argument’)
> ; Root is sqrt(Diff),
> P is (0-B+Root)/(2*A),
> N is (0-B-Root)/(2*A)
> ).
Here's another version of the above with a syntax more suited to a
concatenative language:
quad a b c = p n
where d = b 4 a c * * -
r = d 0 >= [d sqrt] ["quad: sqrt of negative" error] if
x = 2 a *
p = b r - x /
n = b r + x /
Ah, syntax is fun.
- John
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/concatenative/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/concatenative/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/