[Haskell-cafe] Re: iterative algorithms: how to do it in Haskell?
lennart at augustsson.net
Sat Aug 19 15:27:39 EDT 2006
There are much better ways than storing strings on the stack.
Like using a data type with constructors for the different types that
you can store.
On Aug 19, 2006, at 11:51 , Gene A wrote:
> Hi Lennart,
> This morning when I posted..it was about 2:30am and had been up a
> long time... bad habits.. I sent a message to Henk-Jan to that effect,
> but didn't send to the entire list.. anyway thanks to both for the
> followups... I still tend to sometimes do things the hard way in
> Haskell. Started trying to learn it starting in I think Nov-Dec. of
> 2005, so not too awfully long, but with a lot of other things soaking
> up time, not as far along as I wished to be in even this amount of
> time... Most interesting language I have used yet.
> but yes not sure why not the precision.. but I think when I tried
> that with the way I had the thing in the original, I used (**) 1/3
> and got an error message which I was too tired to even read,..and just
> changed it to 0.33333333 or whatever .... however many 3's , and just
> got it posted.. I don't think that those functions are of much use,
> the thing was that when I wrote them, not at 2AM in the morning, I
> remember thinking just how easy it was to do pretty much anything you
> want with this language.. Off topic, but one of my tests of a
> language, old habit this, is as soon as I know enough to be dangerous,
> I try writing a forth interpreter in it. I have started such a thing,
> a module I call Hforth, and it is operational, but do to the nature of
> lists not holding homogeneos values in Haskell everything has to be
> stored with String values. This has the result of having to apply
> show function to store numerics to the stack and then to use the read
> function to convert back when popping the stack.. .. hmm still
> tired... Anyway the upshot is that a very rudimentary interpreter is
> up and running to do simple things with just builtins so far, but was
> built in a matter of some fairly small number of hours. Doesn't
> support line editing yet, so really not too good, but does support
> pushing strings and concatenation and some other things that are more
> tedious to write as primatives in other languages.. The only other
> language that was as easy to get to this stage with was scheme.
> Sorry for the ramble,
> On 8/19/06, Lennart Augustsson <lennart at augustsson.net> wrote:
>> On Aug 19, 2006, at 05:14 , Henk-Jan van Tuyl wrote:
>> > [...]
>> >> *Iteration> fromtoby 12 42 3 (flip (**) 0.3333333333)
>> > fromtoby 12 42 3 (**0.3333333333)
>> And why approximate so much?
>> fromtoby 12 42 3 (** (1/3))
More information about the Haskell-Cafe