Hi,
I was just wondering how easy and how effective is it to create
other data structures in lisp? What is the best way to represent
trees, graphs, and other data structures that we commonly come across
in other languages? For instance, in C, we have the struct keyword to
create almost any type of data structure. How is it accomplished in
lisp and are there any trade offs involved?
Regards,
Abdullah
|
|
0
|
|
|
|
Reply
|
abdullah.ak7 (10)
|
10/26/2009 1:29:31 PM |
|
Abdullah Abdul Khadir <abdullah.ak7@gmail.com> writes:
> Hi,
> I was just wondering how easy and how effective is it to create
> other data structures in lisp? What is the best way to represent
> trees, graphs, and other data structures that we commonly come across
> in other languages? For instance, in C, we have the struct keyword to
> create almost any type of data structure. How is it accomplished in
> lisp and are there any trade offs involved?
defstruct
--
__Pascal Bourguignon__
|
|
0
|
|
|
|
Reply
|
pjb (7647)
|
10/26/2009 1:32:43 PM
|
|
On Mon, 26 Oct 2009 06:29:31 -0700, Abdullah Abdul Khadir wrote:
> Hi,
> I was just wondering how easy and how effective is it to create
> other data structures in lisp? What is the best way to represent trees,
> graphs, and other data structures that we commonly come across in other
> languages? For instance, in C, we have the struct keyword to create
> almost any type of data structure. How is it accomplished in lisp and
> are there any trade offs involved?
CL is (one of) the most advanced computer language(s), so of course it
has support for creating data structures. See defclass and defstruct.
You question indicates that you don't know any Common Lisp. Unless
your question is academic, you should simply start learning the
language instead of worrying about whether it has feature X.
Practical Common Lisp (available online) would be a good place to start.
HTH,
Tamas
|
|
0
|
|
|
|
Reply
|
tkpapp (975)
|
10/26/2009 1:35:54 PM
|
|
On Mon, 26 Oct 2009 06:29:31 -0700 (PDT), Abdullah Abdul Khadir <abdullah.ak7@gmail.com> wrote:
> Hi,
> I was just wondering how easy and how effective is it to create other
> data structures in lisp? What is the best way to represent trees,
> graphs, and other data structures that we commonly come across in
> other languages? For instance, in C, we have the struct keyword to
> create almost any type of data structure. How is it accomplished in
> lisp and are there any trade offs involved?
Lisp has structures too, eg.:
* (defstruct point x y)
POINT
* (make-point)
#S(POINT :X NIL :Y NIL)
You can even give default values to the members of a structure, using
arbitrarily complex Lisp expressions:
* (defstruct point
(x 10)
(y 20))
POINT
* (make-point)
#S(POINT :X 10 :Y 20)
Lisp also supports plain lists, associative lists, property lists,
vectors, multi-dimensional arrays, hash tables, and generic functions
that operate on any user-defined type (see CLOS).
`Effectiveness' only enters the picture if you start worrying about
optimization. You can optimize Lisp code too, but as with any other
language it may worth following the "optimize later" principle[1], at
least until you have really profiled your code and discovered its
bottlenecks. The pesky bastards often like hiding in very surprising
and amusing places.
[1] http://c2.com/cgi/wiki?OptimizeLater
|
|
0
|
|
|
|
Reply
|
keramida (459)
|
10/26/2009 2:58:45 PM
|
|
Abdullah Abdul Khadir wrote:
> Hi,
> I was just wondering how easy and how effective is it to create
> other data structures in lisp? What is the best way to represent
> trees, graphs, and other data structures that we commonly come across
> in other languages? For instance, in C, we have the struct keyword to
> create almost any type of data structure. How is it accomplished in
> lisp and are there any trade offs involved?
Rather than trusting us that its easy, how about reading some real
code which implements these structures and their associated algorithms?
http://common-lisp.net/project/cl-containers/
http://common-lisp.net/project/cl-graph/
http://common-lisp.net/project/fset/
http://www.cliki.net/spatial-trees
http://www.cliki.net/TREES
- Daniel
|
|
0
|
|
|
|
Reply
|
dherring1 (548)
|
10/27/2009 4:27:11 AM
|
|
Tamas K Papp wrote:
> You question indicates that you don't know any Common Lisp. Unless
> your question is academic, you should simply start learning the
> language instead of worrying about whether it has feature X.
I don't believe that "simply start learning the language" is a valid option when compared with a
knowledgeable Lisp hacker providing some insight and supplying some basic examples. And obviously it's in
fact very important to "worry about whether it has feature X". If it doesn't then what's the point of taking
it up?
So please reconsider your "RTFM" reply.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/27/2009 7:25:00 AM
|
|
On Mon, 26 Oct 2009 22:18:42 -0400, Kenneth Tilton wrote:
> Tamas K Papp wrote:
>> CL is (one of) the most advanced computer language(s).
>
> (Which) is it?
Some language features appear to be mutually exclusive, so "more
advanced" is a subjective ordering that depends on the user's
preferences. CL dominates most languages, but eg if you want a purely
functional language[1], you would looks elsewhere.
Besides, saying that [Language X] is the best has a significant
probability of spawning a sub-thread where people engage in meaningless
discussion, which I wanted to avoid. So even though CL is the best
language _for my purposes_, I usually try to refrain from phrasing it
like that.
Tamas
[1]: I cannot tell why you would want that, but there are people who
do.
|
|
0
|
|
|
|
Reply
|
tkpapp (975)
|
10/27/2009 7:43:35 AM
|
|
On Tue, 27 Oct 2009 07:25:00 +0000, Rui Maciel wrote:
> Tamas K Papp wrote:
>
>> You question indicates that you don't know any Common Lisp. Unless
>> your question is academic, you should simply start learning the
>> language instead of worrying about whether it has feature X.
>
> I don't believe that "simply start learning the language" is a valid
> option when compared with a knowledgeable Lisp hacker providing some
> insight and supplying some basic examples. And obviously it's in fact
> very important to "worry about whether it has feature X". If it doesn't
> then what's the point of taking it up?
>
> So please reconsider your "RTFM" reply.
Please consider using your brain.
Can you _really_ imagine any decent language without data structures?
Next time, are you going to ask if Lisp has numbers?
Do you really think you need a "knowledgeable Lisp hacker" to
elaborate on the most basic features of the language?
Do you think that you benefit more from getting general answers to
trivial questions than reading a very well-written book?
Since when does pointing out an excellent introductory book (which the
author kindly made available online) count as RTFM?
Best,
Tamas
|
|
0
|
|
|
|
Reply
|
tkpapp (975)
|
10/27/2009 7:54:10 AM
|
|
Tamas K Papp wrote:
> Please consider using your brain.
If you aren't able to write a message without insulting anyone then it is better not to write it at all.
After all, it's a clear sign you don't have anything to say to begin with.
> Can you _really_ imagine any decent language without data structures?
> Next time, are you going to ask if Lisp has numbers?
You wouldn't have said that nonsense if you had read what I've written.
> Do you really think you need a "knowledgeable Lisp hacker" to
> elaborate on the most basic features of the language?
If someone needs advice on a specific subject then that person will be better off by taking the advice from
someone who is more knowledgeable than him/her. Don't you understand that?
> Do you think that you benefit more from getting general answers to
> trivial questions than reading a very well-written book?
Are you serious? Why should someone be forced to read an entire book (which may even cost you money to access
it) just to be able to get the exact same answer anyone can easily (and even instantly) give you in a small,
half-dozen words message? That suggestion borders the moronic when you realize that those who ask that sort
of questions are usually trying to decide if they should or shouldn't take up that language.
> Since when does pointing out an excellent introductory book (which the
> author kindly made available online) count as RTFM?
You've got to be kidding...
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/27/2009 11:18:51 AM
|
|
On Tue, 27 Oct 2009 11:18:51 +0000, Rui Maciel wrote:
>> Do you think that you benefit more from getting general answers to
>> trivial questions than reading a very well-written book?
>
> Are you serious? Why should someone be forced to read an entire book
Calm down. No one is forcing you to do anything. You got your
answer, but what do you want to do with it? Presumably, program Lisp.
So you have to learn it somehow, and the effort will be greater than
(and also may include) reading that book.
> (which may even cost you money to access it) just to be able to get the
Gosh, I take it back. I now realize that you have to mortgage your
house to pay the cost of reading a fricking book online. What was I
thinking.
>> Since when does pointing out an excellent introductory book (which the
>> author kindly made available online) count as RTFM?
>
> You've got to be kidding...
In my reply to you, I mentioned defclass and defstruct, which was
exactly what you asked for. I _also_ gave you a reference, which was
meant to be helpful.
Anyhow, have fun learning Lisp, if you decide that you want to.
Tamas
|
|
0
|
|
|
|
Reply
|
tkpapp (975)
|
10/27/2009 12:28:21 PM
|
|
Rui Maciel <rui.maciel@gmail.com> writes:
>> Do you really think you need a "knowledgeable Lisp hacker" to
>> elaborate on the most basic features of the language?
>
> If someone needs advice on a specific subject then that person will
> be better off by taking the advice from someone who is more
> knowledgeable than him/her. Don't you understand that?
At this point, I should remark that Wikipedia is more knowledgable
than you. Can you understand our irritation, when the answer to your
trivial questions is given in the first page linked from a search at
google for common lisp?
--
__Pascal Bourguignon__
|
|
0
|
|
|
|
Reply
|
pjb (7647)
|
10/27/2009 12:28:54 PM
|
|
Rui Maciel wrote:
> If you aren't able to write a message without insulting anyone then it is better not to write it at all.
This NG would be nothing but cheap wholesale suit ads if we listened to
you. Moron.
kt
|
|
0
|
|
|
|
Reply
|
kentilton (2964)
|
10/27/2009 6:17:19 PM
|
|
Pascal J. Bourguignon wrote:
> At this point, I should remark that Wikipedia is more knowledgable
> than you.
I've explicitly posted in this group not long ago that I was just starting out at Lisp and I'm still trying
to figure out some stuff, so that isn't necessarily news nor a secret. Yet, what does this have to do with
the subject?
> Can you understand our irritation, when the answer to your
> trivial questions is given in the first page linked from a search at
> google for common lisp?
The only question I posted to this newsgroup so far was the one about implementing modification notifications
on data structures on the thread "Trigger action when operation on a data structure". As a solution it has
been suggested a) reimplementing lists in CLOS (granted it was far from a perfect solution) and b) hack some
Lisp implementation. Maybe we don't share the same definition of "trivial" but I don't believe it applies to
a problem whose solution consists of hacking Lisp implementations.
But let's assume that newbies do irritate some Asperger patients who happen to follow this newsgroup. Still,
no matter how insulted they may feel by seeing newbies posting their innocent, clueless questions to their
pet newsgroup, what good does insulting them do? Do you believe that newbies will perceive the behavior of a
hand-full of morons in a group which has already limited traffic as an incentive to take up this particular
language?
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/27/2009 10:12:01 PM
|
|
Kenneth Tilton wrote:
> This NG would be nothing but cheap wholesale suit ads if we listened to
> you. Moron.
Off the meds, aren't we?
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/27/2009 10:15:29 PM
|
|
Tamas K Papp wrote:
<snip/>
> In my reply to you, I mentioned defclass and defstruct, which was
> exactly what you asked for. I _also_ gave you a reference, which was
> meant to be helpful.
I'm not the original poster (Abdullah Abdul Khadir). Instead of addressing the rest of your post it is best
to simply ask you to re-read the thread.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/27/2009 10:23:54 PM
|
|
Rui Maciel <rui.maciel@gmail.com> writes:
> Pascal J. Bourguignon wrote:
>> At this point, I should remark that Wikipedia is more knowledgable
>> than you.
Sorry, I meant the OP, not you. (Sometimes I have a hard time keeping
track of who answers to who).
> I've explicitly posted in this group not long ago that I was just
> starting out at Lisp and I'm still trying to figure out some stuff,
> so that isn't necessarily news nor a secret. Yet, what does this
> have to do with the subject?
Rehearse the thread.
The OP asked a simple question (has lisp structures?) that shouldn't
have required a "knowledgeable Lisp hacker" to get an answer, since
the wikipedial page about Common Lisp, gives the answer to that
question.
Basically, he's been inconsiderate of the time of the "knowledgeable
lisp hackers" who read this newsgroup and try to help, when he could
and should have read at least the wikipedia article about Common Lisp
and thus would have learned that indeed CL has structures.
>> Can you understand our irritation, when the answer to your
>> trivial questions is given in the first page linked from a search at
>> google for common lisp?
>
> The only question I posted to this newsgroup so far was the one
> about implementing modification notifications on data structures on
> the thread "Trigger action when operation on a data structure".
Indeed. It was not your question, but that of the OP. Sorry.
> Do you believe that newbies will perceive the behavior of a
> hand-full of morons in a group which has already limited traffic as
> an incentive to take up this particular language?
Usually, even these inconsiderate newbies receive good answers. There
may be some additionnal advices such as those given by Tamas. What is
more irritating on the other hand is when the OP (or in the case of
this thread somebody else) complains about these answers given, when
he could have got it faster and with less "emotion" from google or
wikipedia.
--
__Pascal Bourguignon__
|
|
0
|
|
|
|
Reply
|
pjb (7647)
|
10/28/2009 12:14:14 AM
|
|
Rui Maciel wrote:
> Off the meds, aren't we?
A "meds" crack? In 2009? How novel.
kt
|
|
0
|
|
|
|
Reply
|
kentilton (2964)
|
10/28/2009 4:47:37 AM
|
|
kick ass list of linkS!
what are graph algorithms used for comonly?
|
|
0
|
|
|
|
Reply
|
gavcomedy (1610)
|
10/28/2009 6:46:34 AM
|
|
Rui Maciel <rui.maciel@gmail.com> writes:
> Still,
> no matter how insulted they may feel by seeing newbies posting their innocent, clueless questions to their
> pet newsgroup, what good does insulting them do?
I doubt that your questions are innocent, but it is sure that in
addition to clueless they are ill-formatted which makes them a PITA to
read.
Nicolas
|
|
0
|
|
|
|
Reply
|
lastname7788 (201)
|
10/28/2009 8:27:32 AM
|
|
On Tue, 27 Oct 2009 22:12:01 +0000, Rui Maciel wrote:
> The only question I posted to this newsgroup so far was the one about
> implementing modification notifications on data structures on the thread
> "Trigger action when operation on a data structure". As a solution it
> has been suggested a) reimplementing lists in CLOS (granted it was far
> from a perfect solution) and b) hack some Lisp implementation. Maybe we
> don't share the same definition of "trivial" but I don't believe it
> applies to a problem whose solution consists of hacking Lisp
> implementations.
Reimplementing a list-like data structure and/or customized accessors
_is_ the perfect solution to your question.
So, to summarize:
1) you came to this NG with a not-so-clear question,
2) you got a perfect solution,
3) you keep whining.
Cheers,
Tamas
|
|
0
|
|
|
|
Reply
|
tkpapp (975)
|
10/28/2009 8:50:38 AM
|
|
Tamas K Papp wrote:
> On Tue, 27 Oct 2009 22:12:01 +0000, Rui Maciel wrote:
>
>> The only question I posted to this newsgroup so far was the one about
>> implementing modification notifications on data structures on the thread
>> "Trigger action when operation on a data structure". As a solution it
>> has been suggested a) reimplementing lists in CLOS (granted it was far
>> from a perfect solution) and b) hack some Lisp implementation. Maybe we
>> don't share the same definition of "trivial" but I don't believe it
>> applies to a problem whose solution consists of hacking Lisp
>> implementations.
>
> Reimplementing a list-like data structure and/or customized accessors
> _is_ the perfect solution to your question.
The only thing that has been said in that thread regarding implementing a new custom-tailored data structure
was that that functions like map, dolist and loop will not work. That issue alone means that that suggestion
is, to put it lightly, less than perfect.
> So, to summarize:
>
> 1) you came to this NG with a not-so-clear question
I don't believe that that is a crime, is it?
> 2) you got a perfect solution,
Please re-read the thread (it's starting to become a recurring suggestion).
> 3) you keep whining.
If you paid attention to what you've been writing you will notice that your participation in this thread
amounts to nothing more than insulting people along with bitching about nonsensical stuff without even having
a clue about what you are discussing and even to whom you have been replying to. So please refrain from
mentioning whining.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/28/2009 7:05:07 PM
|
|
Nicolas Neuss wrote:
> I doubt that your questions are innocent
Innocent how? Are you talking about some sort of conspiracy?
> but it is sure that in
> addition to clueless they are ill-formatted which makes them a PITA to
> read.
Care to point out what questions you believe to be "ill-formatted"?
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/28/2009 7:06:13 PM
|
|
Pascal J. Bourguignon wrote:
> Sorry, I meant the OP, not you. (Sometimes I have a hard time keeping
> track of who answers to who).
No problem. We're only human.
>> I've explicitly posted in this group not long ago that I was just
>> starting out at Lisp and I'm still trying to figure out some stuff,
>> so that isn't necessarily news nor a secret. Yet, what does this
>> have to do with the subject?
>
> Rehearse the thread.
>
> The OP asked a simple question (has lisp structures?) that shouldn't
> have required a "knowledgeable Lisp hacker" to get an answer, since
> the wikipedial page about Common Lisp, gives the answer to that
> question.
Granted, that question was a bit far-fetched. Nonetheless, when a newbie starts reading any "intro to Lisp"
text then, when reading on the subject of data structures, he will be overwhelmed with a lengthy
explanation on cons, car and cdr and how any user can build all conceivable data structures from that hand-
full of building blocks. If that newbie happens to have a background in any popular interpreted language
or even, for example, C++ then, has he may be expecting a readily-available set of data structures, he may
be left wondering if Lisp does support data structures at all, at least like other languages do.
> Basically, he's been inconsiderate of the time of the "knowledgeable
> lisp hackers" who read this newsgroup and try to help, when he could
> and should have read at least the wikipedia article about Common Lisp
> and thus would have learned that indeed CL has structures.
Yes, that's true, although I wouldn't go as far as saying it was inconsiderate.
<snip/>
> Usually, even these inconsiderate newbies receive good answers.
And that's one of the main reasons why usenet is up to this day (and IMHO) the best expert system ever
devised.
> There
> may be some additionnal advices such as those given by Tamas. What is
> more irritating on the other hand is when the OP (or in the case of
> this thread somebody else) complains about these answers given, when
> he could have got it faster and with less "emotion" from google or
> wikipedia.
If you read my first reply to Tamas you will notice that the only problem I had was with the "RTFM", which
is a non-answer and isn't at all helpful. Just to put it in perspective, I believe you are aware of the
circumstances that drove me to Lisp and how important it is to me to be able to ask questions regarding the
language, even basic ones, before taking up Lisp seriously, let alone spending time reading any manual.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/28/2009 7:51:11 PM
|
|
Kenneth Tilton wrote:
> A "meds" crack? In 2009? How novel.
Your behavior also leads to believe that crack is also a factor. So if you don't have anything useful (or
even remotely intelligent) to say then please waste your time somewhere else. At least I won't waste my time
with your tantrums.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/28/2009 7:58:29 PM
|
|
On Wed, 28 Oct 2009 19:05:07 +0000, Rui Maciel wrote:
> Tamas K Papp wrote:
>
>> Reimplementing a list-like data structure and/or customized accessors
>> _is_ the perfect solution to your question.
>
> The only thing that has been said in that thread regarding implementing
> a new custom-tailored data structure was that that functions like map,
> dolist and loop will not work. That issue alone means that that
> suggestion is, to put it lightly, less than perfect.
Oh dear. "To put it lightly." So what if you can't use the standard
tools? Probably your problem can be still solved very easily in CL.
Yet you are here, whining as if accessing/iterating on a custom data
structure was an insurmountable problem.
>> 3) you keep whining.
>
> If you paid attention to what you've been writing you will notice that
> your participation in this thread amounts to nothing more than insulting
> people along with bitching about nonsensical stuff without even having a
> clue about what you are discussing and even to whom you have been
> replying to. So please refrain from mentioning whining.
So what are we discussing? What is the specific problem you are
trying to solve? Can you provide a working toy example? Mock code?
Etc. People will help you do that if you ask the right questions, so you
might as well start doing that (unless, of course, you prefer posting
aggressive & clueless replies, that's OK too).
Cheers,
Tamas
|
|
0
|
|
|
|
Reply
|
tkpapp (975)
|
10/28/2009 8:33:04 PM
|
|
On Oct 28, 9:51=A0pm, Rui Maciel <rui.mac...@gmail.com> wrote:
<snip>
> Granted, that question was a bit far-fetched. Nonetheless, when a newbie =
starts reading any "intro to Lisp"
> text then, when reading on the subject of data structures, he will be ove=
rwhelmed with a lengthy
> explanation on cons, car and cdr and how any user can build all conceivab=
le data structures from that hand-
> full of building blocks. =A0If that newbie happens to have a background i=
n any popular interpreted language
> or even, for example, C++ then, has he may be expecting a readily-availab=
le set of data structures, he may
> be left wondering if Lisp does support data structures at all, at least l=
ike other languages do.
Then that reader won't be ready to learn lisp, because he'll assume
one of the two:
- lisp arrays have O(n) access since they are built from CONS cells
- O(1) access arrays can be built from CONS cells
To assume the first is illogical, since you're told lisp is The
Greatest Language in the introduction of any good lisp text, all those
authors would make the mistake of contradicting themselves, for a
language/array-impl with O(n) access is trash. That is quite unlikely.
The latter is also obvious: 1 cons cell stores two values, 2 cons
cells store 3 values, leads to x cons cells store x + 1 values (1)
(and in practice 1 is subtracted for the 'nil' ending value).
Therefore an array - which is really just a list or a list* - of
length 3 for example, can't be represented with less than 2 cons
cells, which requires an O(2) operation (2), CAAR and CADR, to reach
for either the second or third value. From (1), (2), x items, O(x)
access.
Some texts, among them lisp texts, compliment the reader by assuming
his intelligence and willingness to think/learn. Unfortunately you'll
have to read a different text (or choose a different language, because
the language does the same), if thinking is not your forte.
|
|
0
|
|
|
|
Reply
|
vippstar (1211)
|
10/28/2009 9:08:58 PM
|
|
On Wed, 28 Oct 2009 19:58:29 +0000, Rui Maciel wrote:
> Kenneth Tilton wrote:
>
>> A "meds" crack? In 2009? How novel.
>
> Your behavior also leads to believe that crack is also a factor. So if
> you don't have anything useful (or even remotely intelligent) to say
> then please waste your time somewhere else. At least I won't waste my
> time with your tantrums.
As much as I like to watch an unarmed person entering into a battle of
wits with Kenny, I think that at this point I should give you this
hint: if you actually asked your question in a reasonably smart way,
the people who you are trying to insult in this thread would have been
the first to help you, and you would have already solved your problem.
That could _still_ happen, despite your bad start here. Read Eric
Raymond's http://catb.org/~esr/faqs/smart-questions.html , and try
again.
HTH,
Tamas
|
|
0
|
|
|
|
Reply
|
tkpapp (975)
|
10/28/2009 9:20:46 PM
|
|
vippstar wrote:
> Then that reader won't be ready to learn lisp, because he'll assume
> one of the two:
> - lisp arrays have O(n) access since they are built from CONS cells
> - O(1) access arrays can be built from CONS cells
I don't know where you got that idea. Projection, maybe? The only thing that a newbie, in that position, will
assume is that they will be forced to hand-craft every data structure they will ever need, which is a serious
let down for those who are used to just take advantage of pre-existing containers.
<snip/>
> Some texts, among them lisp texts, compliment the reader by assuming
> his intelligence and willingness to think/learn. Unfortunately you'll
> have to read a different text (or choose a different language, because
> the language does the same), if thinking is not your forte.
It appears you are confusing previous exposure to specific concepts as being intelligence, which doesn't make
sense.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/28/2009 9:42:56 PM
|
|
Tamas K Papp wrote:
> Oh dear. "To put it lightly." So what if you can't use the standard
> tools? Probably your problem can be still solved very easily in CL.
> Yet you are here, whining as if accessing/iterating on a custom data
> structure was an insurmountable problem.
Are you functionally illiterate? You try to preach about the virtues of asking questions the smart way but
then it turns out you even fail to follow the most basic principles you are trying to use as a way to demean
others.
So please. Just read what has been already posted. And put in some effort this time. I don't even expect, let
alone ask, you to reply afterwards. Just read it and, instead of shoving your foot in your mouth, try to at
least take it out of it for a change.
> So what are we discussing?
By the number of times you've demonstrated you kept missing the point and by the number of times I've asked
you to simply read what has been posted... Well, it doesn't surprise anyone that you don't have a clue about
what is being discussed. So instead of wasting my time with lost causes who suffer from some sort of
inferiority complex I'll simply stop replying to you from now on.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/28/2009 10:13:53 PM
|
|
vippstar wrote:
> Then that reader won't be ready to learn lisp, because he'll assume
> one of the two:
> - lisp arrays have O(n) access since they are built from CONS cells
> - O(1) access arrays can be built from CONS cells
>
> ...
>
> The latter is also obvious: 1 cons cell stores two values, 2 cons
> cells store 3 values, leads to x cons cells store x + 1 values (1)
> (and in practice 1 is subtracted for the 'nil' ending value).
> Therefore an array - which is really just a list or a list* - of
> length 3 for example, can't be represented with less than 2 cons
> cells, which requires an O(2) operation (2), CAAR and CADR, to reach
> for either the second or third value. From (1), (2), x items, O(x)
> access.
Actually, cons cells can be used to make an O(log n) access array. Build
a binary tree; to get cell N, go from the root left or right depending
on the first bit of N, then left or right depending on the second bit of
N, etc.
|
|
0
|
|
|
|
Reply
|
searles (445)
|
10/29/2009 7:06:14 AM
|
|
Rui Maciel wrote:
> vippstar wrote:
>
>> Then that reader won't be ready to learn lisp, because he'll assume
>> one of the two:
>> - lisp arrays have O(n) access since they are built from CONS cells
>> - O(1) access arrays can be built from CONS cells
>
> I don't know where you got that idea. Projection, maybe? The only thing that a newbie, in that position, will
> assume is that they will be forced to hand-craft every data structure they will ever need, which is a serious
> let down for those who are used to just take advantage of pre-existing containers.
Or at best go hunting around for a third-party library that will need to
be installed, configured, etc.
|
|
0
|
|
|
|
Reply
|
searles (445)
|
10/29/2009 7:06:52 AM
|
|
Tamas K Papp wrote:
> On Wed, 28 Oct 2009 19:58:29 +0000, Rui Maciel wrote:
>> Kenneth Tilton wrote:
>>> A "meds" crack? In 2009? How novel.
>> Your behavior also leads to believe that crack is also a factor. So if
>> you don't have anything useful (or even remotely intelligent) to say
>> then please waste your time somewhere else. At least I won't waste my
>> time with your tantrums.
>
> As much as I like to watch an unarmed person entering into a battle of
> wits with Kenny, I think that at this point I should give you this
> hint: if you actually asked your question in a reasonably smart way,
> the people who you are trying to insult in this thread would have been
> the first to help you, and you would have already solved your problem.
>
> That could _still_ happen, despite your bad start here. Read Eric
> Raymond's http://catb.org/~esr/faqs/smart-questions.html , and try
> again.
Condescending response duly noted.
|
|
0
|
|
|
|
Reply
|
searles (445)
|
10/29/2009 7:10:45 AM
|
|
Hi,
First of all I am grateful to all those (especially the expert
hackers) who took time out to answer my "silly" question.
Unfortunately, I did not check this post since I originally posted it
until today and I apologize for not replying earlier and clearing a
few misunderstandings which I hope to do so now.
To shed some light on why I asked that question allow me to
narrate to you I have already read. I am not exactly a beginner to
lisp and I know a fair amount of it. Also I am from a CS background
and I am currently doing my Masters in Computer Science.
I also maintain a blog dedicated to linux and lisp. You may check
http://linuxandlisp.blogspot.com/search/label/lisp-interpreter for
posts discussing a lisp interpreter (which is basically the
interpreter that Paul Graham had on his site) in detail. Also I am a
fan of emacs and emacs lisp and a few posts discussing emacs lisp can
be found here http://linuxandlisp.blogspot.com/search/label/emacs-lisp.
I have read quite a few books in lisp and as somebody had
suggested I have read "Practical Common Lisp". I have not read
anything completely though, including Practical Common Lisp and I
don't think I really have to read it completely as I am not really
interested in understanding whatever the author has explained. Yes,
the author did speak of data structures but not in the way that I am
interested in. Have a look at http://gigamonkeys.com/book/beyond-lists-other-uses-for-cons-cells.html
where he talks about trees but he uses cons cells to build trees and I
doubt that we can even build binary trees in a clean manner using cons
cells. The reason I do not want to read any book completely is because
I have a very basic question and unless that is answered I do not see
any reason why I should labour on in any book and that is the reason
why I am here so that we may have a fruitful discussion on what lisp
can and cannot do.
From whatever I have seen and read of lisp, I could not find
anything like struct in C. Anyhow thanks to all those who pointed out
defclass and defstruct. I have to read it yet and see if it will suit
my purposes. The main purpose for me to learn lisp is because of the
brevity in expressing algorithms. Hence I want to write algorithms in
lisp and see things clearly which is not possible in other languages
because of the typing systems and other conventions in place. However,
from what I had seen of lisp (which is very little compared to the
experts on this group) it did not seem to have a very easy way of
creating data structures that use pointers and the like. Again thanks
to D Herring for pointing the links to me. I will check them soon.
Thus to conclude the main reason that motivated me to learn lisp
was the brevity and effective manner in which algorithms could be
expressed in it. Two years down the lane after a lot of tutorials,
after learning haskell, and other things I am yet to realise how to
create data structures from scratch in an easy way. I do not want
containers I never used them in C++, in fact I never used C++. All I
want is ways to create data structures without recourse some bizzarre
things like lambda calculus and anonymous functions (which are pretty
cool) but not exactly what I need right now.
Regards and Thank You for your time and effort,
Abdullah.
|
|
0
|
|
|
|
Reply
|
abdullah.ak7 (10)
|
10/29/2009 5:45:47 PM
|
|
On Oct 29, 2:08=A0am, vippstar <vipps...@gmail.com> wrote:
> On Oct 28, 9:51=A0pm, Rui Maciel <rui.mac...@gmail.com> wrote:
> <snip>
>
> > Granted, that question was a bit far-fetched. Nonetheless, when a newbi=
e starts reading any "intro to Lisp"
> > text then, when reading on the subject of data structures, he will be o=
verwhelmed with a lengthy
> > explanation on cons, car and cdr and how any user can build all conceiv=
able data structures from that hand-
> > full of building blocks. =A0If that newbie happens to have a background=
in any popular interpreted language
> > or even, for example, C++ then, has he may be expecting a readily-avail=
able set of data structures, he may
> > be left wondering if Lisp does support data structures at all, at least=
like other languages do.
>
> Then that reader won't be ready to learn lisp, because he'll assume
> one of the two:
> - lisp arrays have O(n) access since they are built from CONS cells
> - O(1) access arrays can be built from CONS cells
Yes exactly !!! This is one of the questions that I have but somehow
CL does have arrays and I am curious to know how it implements them.
|
|
0
|
|
|
|
Reply
|
abdullah.ak7 (10)
|
10/29/2009 5:59:12 PM
|
|
Abdullah Abdul Khadir <abdullah.ak7@gmail.com> writes:
> On Oct 29, 2:08�am, vippstar <vipps...@gmail.com> wrote:
>> Then that reader won't be ready to learn lisp, because he'll assume
>> one of the two:
>> - lisp arrays have O(n) access since they are built from CONS cells
>> - O(1) access arrays can be built from CONS cells
>
> Yes exactly !!! This is one of the questions that I have but somehow
> CL does have arrays and I am curious to know how it implements them.
Not really, you are not curious to know it. Otherwise you would be
reading the sources instead of posting long posts about how you are
avoiding to learn lisp for two years.
--
__Pascal Bourguignon__
|
|
0
|
|
|
|
Reply
|
pjb (7647)
|
10/29/2009 6:03:29 PM
|
|
On Oct 29, 2:42=A0am, Rui Maciel <rui.mac...@gmail.com> wrote:
> vippstar wrote:
> > Then that reader won't be ready to learn lisp, because he'll assume
> > one of the two:
> > - lisp arrays have O(n) access since they are built from CONS cells
> > - O(1) access arrays can be built from CONS cells
>
> I don't know where you got that idea. Projection, maybe? The only thing t=
hat a newbie, in that position, will
> assume is that they will be forced to hand-craft every data structure the=
y will ever need, which is a serious
> let down for those who are used to just take advantage of pre-existing co=
ntainers.
I do want to hand-craft most of the data structures and I do not have
any previous exposure to containers as I never used C++ much. Most of
the programs that I have written were either in C or java before
coming across the functional paradigm.
Abdullah.
|
|
0
|
|
|
|
Reply
|
abdullah.ak7 (10)
|
10/29/2009 6:04:55 PM
|
|
On Thu, 29 Oct 2009 10:45:47 -0700, Abdullah Abdul Khadir wrote:
> cells. The reason I do not want to read any book completely is because I
> have a very basic question and unless that is answered I do not see any
> reason why I should labour on in any book and that is the reason why I
> am here so that we may have a fruitful discussion on what lisp can and
> cannot do.
Well, if you don't feel like making the effort of reading the books, I
don't think many people will really feel like helping you. RTFM
first.
> expressed in it. Two years down the lane after a lot of tutorials, after
> learning haskell, and other things I am yet to realise how to create
> data structures from scratch in an easy way. I do not want containers I
Please tell me that I misunderstand. You haven't actually been
learning Lisp for TWO YEARS before asking your question.
> never used them in C++, in fact I never used C++. All I want is ways to
> create data structures without recourse some bizzarre things like lambda
> calculus and anonymous functions (which are pretty cool) but not exactly
> what I need right now.
Yeah, I have the same attitude about human languages. _All_ I want is
to read Doctor Zhivago in the original. Why should I learn Russian
with all those bizarre characters and conjugation for that? That's
not exactly what I need right now.
Tamas
|
|
0
|
|
|
|
Reply
|
tkpapp (975)
|
10/29/2009 6:15:59 PM
|
|
Abdullah Abdul Khadir <abdullah.ak7@gmail.com> writes:
> I do want to hand-craft most of the data structures and I do not have
> any previous exposure to containers as I never used C++ much. Most of
> the programs that I have written were either in C or java before
> coming across the functional paradigm.
>
> Abdullah.
Dear Abdullah,
could you please provide as with a verbal description of a sample data
structure you have in mind?
It will help in showing you the monkey style of learning lisp: By
examples.
Thank you very much.
Frank
|
|
0
|
|
|
|
Reply
|
dg1sbg1 (135)
|
10/29/2009 6:30:58 PM
|
|
On 2009-10-29, Abdullah Abdul Khadir <abdullah.ak7@gmail.com> wrote:
> From whatever I have seen and read of lisp, I could not find
> anything like struct in C. Anyhow thanks to all those who pointed out
> defclass and defstruct.
We are to believe that you are incapable of Googling for the terms
"lisp structure".
Or, in a document reader, incapable of typing Ctrl-F (or whatever hotkey brings
up the search UI) and searching for the substring "struct".
Is your diaper full? Do you need burping?
|
|
0
|
|
|
|
Reply
|
kkylheku (2499)
|
10/29/2009 8:36:38 PM
|
|
On Thu, 29 Oct 2009 10:45:47 -0700 (PDT), Abdullah Abdul Khadir <abdullah.ak7@gmail.com> wrote:
> I do not want containers I never used them in C++, in fact I never
> used C++. All I want is ways to create data structures without
> recourse some bizzarre things like lambda calculus and anonymous
> functions (which are pretty cool) but not exactly what I need right
> now.
Depending on how you squint your eyes when you look at them *all* Lisp
symbols are 'containers', in the sense that you normally do not have to
dig down to the level of bytes, memory words, pointers and friends.
Lisp does not _stop_ you from doing that[1], but it might be slightly
less comfortable than using higher-level constructs. Keep hacking at
your data structures using the sequences, multi-dimensional arrays,
structs and classes that Lisp provides and, most importantly, keep
having *fun* with the algorithms you are coding :-)
[1] In fact, whenever I have to do exploratory programming that fiddles
bits and bytes and multi-byte words, I always reach for my CLISP and
SBCL images. Almost nothing beats having a full Lisp environment at
hand when looking at binary data for me.
|
|
0
|
|
|
|
Reply
|
keramida (459)
|
10/29/2009 11:20:24 PM
|
|
Dave Searles wrote:
> Or at best go hunting around for a third-party library that will need to
> be installed, configured, etc.
Yes, that's also possible. But all the work associated with the use of a 3rd-party library, which you pointed
out, doesn't look as appealing as simply relying on a component which is already a part of the standard
library.
Rui Maciel
|
|
0
|
|
|
|
Reply
|
rui.maciel (1746)
|
10/29/2009 11:45:54 PM
|
|
On 29 Oct 2009 18:15:59 GMT, Tamas K Papp <tkpapp@gmail.com> said:
> ...
> Yeah, I have the same attitude about human languages. _All_ I want is
> to read Doctor Zhivago in the original. Why should I learn Russian
> with all those bizarre characters and conjugation for that? That's
> not exactly what I need right now.
For the record, the characters of the Cyrillic alphabet are not in
the least bizarre.
(Incidentally, people who recommend _Doctor Zhivago_ also recommend
_The Master and Margarita_.)
---Vassil.
--
"Even when the muse is posting on Usenet, Alexander Sergeevich?"
|
|
0
|
|
|
|
Reply
|
vnikolov1 (276)
|
10/30/2009 3:05:20 AM
|
|
On Thu, 29 Oct 2009 10:59:12 -0700 (PDT), Abdullah Abdul Khadir <abdullah.ak7@gmail.com> said:
> ...
> CL does have arrays and I am curious to know how it implements them.
Like most languages, basically by allocating a contiguous block of
memory large enough to hold all elements of the array, plus a little
extra space for the internal use of the implementation to hold
information about the array (most importantly its rank and
dimensions). I suppose a more specific question has more chance of
getting a better answer.
---Vassil.
--
"Even when the muse is posting on Usenet, Alexander Sergeevich?"
|
|
0
|
|
|
|
Reply
|
vnikolov1 (276)
|
10/30/2009 3:10:05 AM
|
|
Vassil Nikolov <vnikolov@pobox.com> writes:
> For the record, the characters of the Cyrillic alphabet are not in
> the least bizarre.
>
> (Incidentally, people who recommend _Doctor Zhivago_ also recommend
> _The Master and Margarita_.)
As I recall, some of the characters in both _Zhivago_ and _The Master
and Margarita_ were very bizarre indeed. _The Twelve Chairs_ is also
highly recommended, at least when it comes to bizarre characters, as is
Ostrovsky's wonderfully (though unintentionally) absurd _How the Steel
was Tempered_.
--
Aatu Koskensilta (aatu.koskensilta@uta.fi)
"Wovon mann nicht sprechen kann, dar�ber muss man schweigen"
- Ludwig Wittgenstein, Tractatus Logico-Philosophicus
|
|
0
|
|
|
|
Reply
|
aatu.koskensilta1 (232)
|
10/31/2009 2:08:36 AM
|
|
On Oct 28, 7:46=A0am, gavino <gavcom...@gmail.com> wrote:
> kick ass list of linkS!
>
> what are graph algorithms used for comonly?
Best gavino post ever!
|
|
0
|
|
|
|
Reply
|
tburdick (336)
|
11/3/2009 11:51:29 AM
|
|
|
44 Replies
48 Views
(page loaded in 0.53 seconds)
Similiar Articles: data structure, fread, find - comp.soft-sys.matlabHello What i am trying to is that read only numbers from the below data structure 0ÌÌÌÌ+2.650ÌÌÌÌ-29.005ÌÌÌÌ+2.325ÌÌÌÌ+36.89ÌÌÌÌ+34.26ÌÌÌÌ-37 ... data structures abstraction and design using java 2nd edition free ...i m a student so plz tell me how can i get data structures abstraction and design using java 2nd edition free download?????... Stacks Queues and other data structures. - comp.lang.pascal.misc ...Before anyone asks, no I didnt go back to school, so it's not homework...:-) with what's available in the FCL and/or data structure coding practice ... Data Structure Using Proc Transpose - comp.soft-sys.sasHi All: This is the problem I am running in to when I try flipping the data using Proc transpose data work.have; infile datalines tru... get the data from struct - comp.soft-sys.matlab"sscnekro " <stiahni.mail@zoznam.sk> wrote in message <hup09f$f13$1@fred.mathworks.com>... > I don't really know to use structures, but maybe to start, here is ... Hierarchical data structure from a multi-dimensional array - comp ...Hi all, I would appreciate any help. I have a multi-dimensional array representing the column and row dimensions in a table and values in the t... SCSI CDB response data structure - comp.periphs.scsiHi, I'm working with a USB mass storage device that accepts SCSI commands, and I'm trying to understand what this device supports. Are there any softw... Speed-up the reading of large binary files with complex structures ...Hi, I am trying to read a large binary file where the data is structured in a known format composed by a variable number of blocks. Also, these blo... puttygen: Couldn't load private key (unable to create key data ...Follow-Ups: Re: puttygen: Couldn't load private key (unable to create key data structure) From: Simon Tatham; Re: puttygen: Couldn't load private key (unable to ... Structure to matrix - comp.soft-sys.matlabI imported my data with the command importdata(filename) and return a struct s.a with the headlines and the headcolumns of my data and s.b with the... Load data/.mat-file in Simulink - comp.soft-sys.matlabHello all, I have a Matlab function which imports and uses data from a .mat file. This is held in an array of structures, with each structure holdi... Performance: struct vs. cell array - comp.soft-sys.matlab ...cell_array = template; % Create a struct with the % same data. structure = struct('data',0); for n = 1:N structure(n).data = template{n ... Access multiple structures within cell array - comp.soft-sys ...mycell{2,:} gives me all the structures I want to look at mycell{2,1}.info gives me the data (a 10x1 matix) I want from a particular cell mycell{2,:}.info ... Pointers to global and stack variables - comp.compilersNormally having dynamically allocated data structures stored in the activation records of routines is a no no, that would make a teacher of good coding practices hit the ... Passing entire handles structure from 1 gui to another - comp.soft ...My problem mainly lies in that once the gui_2 is closed I no longer have access to the data in the handles structure. Any ideas would be appreciated. Data structure - Wikipedia, the free encyclopediaIn computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. Different kinds of data ... List of data structures - Wikipedia, the free encyclopediaBoolean (for boolean values True/False) Char (for character values) Float (for storing real number values) Double (a larger size of type float) int (for integral or ... 7/23/2012 6:48:22 PM
|