From: CHRISTOS TTINIOZOU
Subject: Infix  to  Prefix .
Date: 
Message-ID: <uML5M$Mf#GA.126@upnetnews02.moswest.msn.net>
I am trying to write a function that takes an  expression

    ( ( - ( 3 + (4 - (-2 ) ) ) )  /   3 ) )  where the operators are  in the
more

familiar  infix  form  (this expression can  not  be evaluated by the
interpreter of lisp)

end CONVERT it into prefix form that could be evaluated by lisp interpreter

  ( / ( - ( + 3 ( - 4 ( - 2 ) ) ) )  3  )

Also  how can  I  do this if the operators are n-ary.


Thanks Chris

From: Kent M Pitman
Subject: Re: Infix  to  Prefix .
Date: 
Message-ID: <sfwwvzvw59f.fsf@world.std.com>
"CHRISTOS TTINIOZOU" <··········@email.msn.com> writes:

> I am trying to write a function that takes an  expression
> 
>     ( ( - ( 3 + (4 - (-2 ) ) ) )  /   3 ) )  where the operators are  in the
> more
> 
> familiar  infix  form  (this expression can  not  be evaluated by the
> interpreter of lisp)
> 
> end CONVERT it into prefix form that could be evaluated by lisp interpreter
> 
>   ( / ( - ( + 3 ( - 4 ( - 2 ) ) ) )  3  )
> 
> Also  how can  I  do this if the operators are n-ary.

Pardon me for venting, but ...

Surely this is homework.  If it is, and you didn't say so, your first
lesson is that I, at least, consider it unethical ever to present a
homework problem to someone else without so labeling it.

I am balso affled by the fact that this question comes up so much.  Do
people just assign these things without giving any classroom time
explaining how to do them?  Surely there is an accompanying class or
textbook that explains this.  I have seen dozens.  We always seem to
end up answering it as if that was a good use of our time, but there
is almost always a textbook going along with these classes that shows
the whole thing with pictures and everything, if the student would just
open it and look at it.

Finally, this question is fundamentally not about Lisp.  It is about
programming in general.  There is very little that can be shown about
"how to do it" that is not "this is the answer", and the only way to
answer it is to know what accompanying stuff the instructor has given
and what is the part that the student is left to discover, so as not
to spoil the drama.
From: Kenneth P. Turvey
Subject: Re: Infix  to  Prefix .
Date: 
Message-ID: <slrn7gf6es.bg8.kturvey@pug1.sprocketshop.com>
On Fri, 2 Apr 1999 12:55:56 GMT, Kent M Pitman <······@world.std.com> wrote:
>Pardon me for venting, but ...
>
>Surely this is homework.  If it is, and you didn't say so, your first
>lesson is that I, at least, consider it unethical ever to present a
>homework problem to someone else without so labeling it.

I wonder whether the prof reads this newsgroup :-) 

>I am also baffled by the fact that this question comes up so much.  Do
>people just assign these things without giving any classroom time
>explaining how to do them?  Surely there is an accompanying class or
>textbook that explains this.  I have seen dozens.  We always seem to
>end up answering it as if that was a good use of our time, but there
>is almost always a textbook going along with these classes that shows
>the whole thing with pictures and everything, if the student would just
>open it and look at it.

We actually just assigned a similar problem to a group of students in
the second programming course in computer science (based on C).  I was a
bit amazed at how much difficulty it seemed to present them.  Given the
algorithm and the tools necessary to implement it, the implementation
step was still quite difficult for most of them.   

I think we tend to forget how hard things are to accomplish the first
time we try.  Everything is easy the second time you do it :-). 

>Finally, this question is fundamentally not about Lisp.  It is about
>programming in general.  There is very little that can be shown about
>"how to do it" that is not "this is the answer", and the only way to
>answer it is to know what accompanying stuff the instructor has given
>and what is the part that the student is left to discover, so as not
>to spoil the drama.

-- 
Kenneth P. Turvey <·······@SprocketShop.com> 

  I would rather be exposed to the inconveniences attending too much
  liberty than those attending too small a degree of it. 
	-- Thomas Jefferson
From: Kent M Pitman
Subject: Re: Infix  to  Prefix .
Date: 
Message-ID: <sfwemm0rs5u.fsf@world.std.com>
·······@pug1.sprocketshop.com (Kenneth P. Turvey) writes:

> I think we tend to forget how hard things are to accomplish the first
> time we try.  Everything is easy the second time you do it :-). 

I didn't mean to suggest it was easy.  Only that it required few
steps.  I was essentially agreeing with your claim.  But the problem
is that it's something like opening those aspirin bottles that are
child-proof.  If you don't know the answer, it's hard.  But if it was
a homework problem, it'd be hard to know how to give someone a hint
without showing them the secret.  It's only one step.  Parsing is a
little harder than that, but the real issue isn't the parsing--it's
what was the instructor trying to teach by assigning the parsing.
Without knowing that, one might offer a "hint" which kept the student
from learning the one part that had caused the instructor to assign it.
Not that all assignments have only one thing you're supposed to learn,
but I think good assignments do have few or one things to learn just
so that it's easy to spot the right thing when it comes along.

> >Finally, this question is fundamentally not about Lisp.  It is about
> >programming in general.  There is very little that can be shown about
> >"how to do it" that is not "this is the answer", and the only way to
> >answer it is to know what accompanying stuff the instructor has given
> >and what is the part that the student is left to discover, so as not
> >to spoil the drama.
> 
> -- 
> Kenneth P. Turvey <·······@SprocketShop.com> 
> 
>   I would rather be exposed to the inconveniences attending too much
>   liberty than those attending too small a degree of it. 
> 	-- Thomas Jefferson
From: Kenneth P. Turvey
Subject: Re: Infix  to  Prefix .
Date: 
Message-ID: <slrn7ggck4.dmu.kturvey@pug1.sprocketshop.com>
On Sun, 4 Apr 1999 21:29:17 GMT, Kent M Pitman <······@world.std.com> wrote:
>
>I didn't mean to suggest it was easy.  Only that it required few
>steps.  I was essentially agreeing with your claim.  But the problem
>is that it's something like opening those aspirin bottles that are
>child-proof.  If you don't know the answer, it's hard.  But if it was
>a homework problem, it'd be hard to know how to give someone a hint
>without showing them the secret.  It's only one step.  Parsing is a
>little harder than that, but the real issue isn't the parsing--it's
>what was the instructor trying to teach by assigning the parsing.
>Without knowing that, one might offer a "hint" which kept the student
>from learning the one part that had caused the instructor to assign it.
>Not that all assignments have only one thing you're supposed to learn,
>but I think good assignments do have few or one things to learn just
>so that it's easy to spot the right thing when it comes along.

I wasn't suggesting that any hints should be provided.  There really
isn't any way to help the poster without more information (and without
completely giving away the answer). 


-- 
Kenneth P. Turvey <·······@SprocketShop.com> 

  I would rather be exposed to the inconveniences attending too much
  liberty than those attending too small a degree of it. 
	-- Thomas Jefferson