[Haskell-cafe] Function to cast types

Anonymous Anonymous temp.public at gmail.com
Sun Mar 22 10:38:29 EDT 2009


an answer from me, this is NOT the homework assignment. For my own homework
assignment, I had to create custom data types and convert a string
containing my datatype into my datatype. I will not expose my datatype, but
it is something with logical operators.

My approach would be using "operator recognition", I've written a function
that can search those "operators". However I was wondering how they would do
it with intergers because intergers are in a infinity set! But I couldn't
figure it out =(.

Thanks for answering you all!

2009/3/22 John Dorsey <haskell at colquitt.org>

> Anonymous One,
> > I'm new to haskell, I'm wondering how can you write a function that will
> do
> > the following:
> > fromIntToString :: Int -> String
> Is this a homework assignment, perchance?  Please take a look at
> http://www.haskell.org/haskellwiki/Homework_help
> Everyone here is glad to help, but we're also sensitive on academic
> honesty.
> With that said, you've done the first step, which is writing down the
> function's type.  You don't want to iterate over all possible Int
> values, so maybe a recursive definition is in order.  What are the cases
> to consider?  Like, what happens if you have a negative number...
> > this is a cast function to cast an Int to a String. I know such function
> By the way, "cast" is probably the wrong word for what you want.  You're
> building a string representation of an Integer; in my view it's not "just"
> a type conversion.
> Good luck,
> John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090322/2ec9cc1e/attachment.htm

More information about the Haskell-Cafe mailing list