Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #45640
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Topological sort |
| Date | 2016-02-20 11:13 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2016Feb20.121311@mips.complang.tuwien.ac.at> (permalink) |
| References | <na80e0$ov$1@dont-email.me> <62b38622-4fbc-4d99-a93d-6c0933e54de5@googlegroups.com> |
lehs <skydda.barnen@gmail.com> writes:
>Since Forth is a kind of macro assembler you'll have to define some kind of=
> lists and sets and then use e.g. Kahn's algorithm.
For some values of "some kind of". There are no sets or lists in the
usual sense in the following program:
: node ( "name" -- )
create
true ,
['] noop ,
does> ( -- )
dup @ if
false over !
dup cell+ @ execute
body> >name name>string type space
else
drop then ;
: before ( xt "name" -- )
' >body cell+ ! ;
\ nodes
node shirt
node tie
node belt
node jacket
node watch
node pants
node shoes
node undershorts
node socks
\ edges
:noname shirt ; before tie
:noname shirt pants ; before belt
:noname tie belt ; before jacket
:noname pants undershorts socks ; before shoes
:noname undershorts ; before pants
\ now sort the nodes:
shirt tie belt jacket watch pants shoes undershorts socks
cr bye
- 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: http://www.forth200x.org/forth200x.html
EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Topological sort "WJ" <w_a_x_man@yahoo.com> - 2016-02-19 21:11 +0000
Re: Topological sort lehs <skydda.barnen@gmail.com> - 2016-02-19 23:41 -0800
Re: Topological sort lehs <skydda.barnen@gmail.com> - 2016-02-20 01:00 -0800
Re: Topological sort anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-20 11:13 +0000
Re: Topological sort lehs <skydda.barnen@gmail.com> - 2016-02-20 10:39 -0800
Rosettacode topological sort (was: Topological sort) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-22 07:54 +0000
Re: Rosettacode topological sort (was: Topological sort) Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-22 10:04 +0000
Re: Rosettacode topological sort (was: Topological sort) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-22 12:26 +0000
Re: Rosettacode topological sort (was: Topological sort) Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-22 13:28 +0000
Re: Topological sort lehs <skydda.barnen@gmail.com> - 2016-02-23 01:12 -0800
Re: Topological sort lehs <skydda.barnen@gmail.com> - 2016-02-23 10:56 -0800
csiph-web