Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #45159

Re: Dynamic programming in Forth

Newsgroups comp.lang.forth
Date 2016-01-28 07:32 -0800
References <3cc99bb7-98df-41b6-a313-2e64e8a83e5c@googlegroups.com> <93276a60-9031-4e08-9988-300631796a4b@googlegroups.com> <2e62d36e-69f6-413d-9e45-1200e649649b@googlegroups.com>
Message-ID <ecb59d5a-d182-45aa-b98b-ebea8bd4b26c@googlegroups.com> (permalink)
Subject Re: Dynamic programming in Forth
From Julian Fondren <julian.fondren@gmail.com>

Show all headers | View raw


On Thursday, January 28, 2016 at 7:04:20 AM UTC-6, lehs wrote:
> I'm certain that I have implemented a sort of lists

If all you mean by 'list' is 'some kind of ordered, nestable data
datastructure', yes, you've made that.  But you haven't made a list,
and if you would accept that instead of writing hateful 'apologies',
then you could get on with the interesting business of elaborating
on the actual properties of your data structure and how they differ
from the properties of other data structures, such as lists.

What kinds of operations can be done to your sequences, and how
efficient are they?  Getting the length of a list is a costly O(N)
operation that involves walking the entire list.  You wouldn't do
that in a loop.  You would rather get the length once and keep that
number around in a variable while you need it.  Getting the length
of *your* sequences though is just DUP NEGATE -- but only for the
*flattened length*.  Which might actually be what you usually want
because that number allows you to iterate neatly over the whole
structure.  If on the other hand you want the usual meaning of
length, then you still have to walk the entire structure to get that
number, and you would still cache it and avoid asking for it in a
loop.  But at least you don't have worry about circular lists when
you get it: you immediately have an upper bound for the length.


> that ... can be used for dynamic programming
> 

How do you store files?  In a string, obviously.  Length.  A bunch
of bytes.  Wait, I mean, you store it in array, obviously.  Length.
A bunch of 64-byte lines.  Wait, I mean, you store it in a hashmap,
obviously.  Because your file consists of 'key: value' pairs with
unique keys that's to serve as the configuration of your app.  Wait,
I mean, you store it as 64-bit cells on the stack, obviously,
because all you're going to do is XOR this file with a one-time-pad
and write it back out, and it amuses you to use the stack to "avoid
memory management".

What data structures can be used for working with files?  Strings,
arrays, hashmaps, and your data structure.  But it is not very
enlightening to say that.


-- Julian

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Dynamic programming in Forth lehs <skydda.barnen@gmail.com> - 2016-01-28 03:07 -0800
  Re: Dynamic programming in Forth lehs <skydda.barnen@gmail.com> - 2016-01-28 03:53 -0800
  Re: Dynamic programming in Forth Julian Fondren <julian.fondren@gmail.com> - 2016-01-28 04:06 -0800
    Re: Dynamic programming in Forth lehs <skydda.barnen@gmail.com> - 2016-01-28 05:04 -0800
      Re: Dynamic programming in Forth Teodor Kanchev <t.kanchev36@gmail.com> - 2016-01-28 05:18 -0800
      Re: Dynamic programming in Forth Julian Fondren <julian.fondren@gmail.com> - 2016-01-28 07:32 -0800
        Re: Dynamic programming in Forth lehs <skydda.barnen@gmail.com> - 2016-01-28 08:29 -0800
    Re: Dynamic programming in Forth "WJ" <w_a_x_man@yahoo.com> - 2016-01-28 16:31 +0000
      Re: Dynamic programming in Forth Julian Fondren <julian.fondren@gmail.com> - 2016-01-28 08:37 -0800
  Re: Dynamic programming in Forth Teodor Kanchev <t.kanchev36@gmail.com> - 2016-01-28 04:24 -0800
    Re: Dynamic programming in Forth "WJ" <w_a_x_man@yahoo.com> - 2016-01-28 14:46 +0000
  Re: Dynamic programming in Forth "WJ" <w_a_x_man@yahoo.com> - 2016-01-28 15:22 +0000
    Re: Dynamic programming in Forth lehs <skydda.barnen@gmail.com> - 2016-01-28 08:13 -0800
  Re: Dynamic programming in Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-28 17:16 +0000
    Re: Dynamic programming in Forth lehs <skydda.barnen@gmail.com> - 2016-01-28 09:57 -0800
  Re: Dynamic programming in Forth lehs <skydda.barnen@gmail.com> - 2016-02-02 12:09 -0800
    Re: Dynamic programming in Forth lehs <skydda.barnen@gmail.com> - 2016-02-19 10:12 -0800

csiph-web