[Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Chung-chieh Shan
Daniel Carrera <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in gmane.comp.lang.haskell.cafe: > [EMAIL PROTECTED] wrote: > > you may use a tuple? > Hhhmm... I just tried it. It looks like Hugs doesn't like tuples with > more than 5 elements. :-( You can nest tuples. And that might be

Re: [Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Sebastian Sylvan
On 5/7/05, Daniel Carrera <[EMAIL PROTECTED]> wrote: > > Stefan Monnier wrote: > >>I have a lady friend who wants to learn how to program. She's a technical > >>person, but has no math background to speak of. I can't decide whether to > >>start with a clear-syntax imperative language (Ruby) or a f

Re: [Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread David Roundy
On Sat, May 07, 2005 at 12:40:55PM -0400, Daniel Carrera wrote: > In your opinion, do you think Haskell is appropriate for someone with > zero math background? I can't imagine how I'd explain something like > currying to someone who doesn't know math. I'd think it'd be pretty easy for a non-math

Re: [Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Daniel Carrera
Stefan Monnier wrote: I have a lady friend who wants to learn how to program. She's a technical person, but has no math background to speak of. I can't decide whether to start with a clear-syntax imperative language (Ruby) or a functional language (Haskell). I confess I've been leaning towards Ruby

[Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Stefan Monnier
> I have a lady friend who wants to learn how to program. She's a technical > person, but has no math background to speak of. I can't decide whether to > start with a clear-syntax imperative language (Ruby) or a functional > language (Haskell). I confess I've been leaning towards Ruby. In my limit

Re: [Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Daniel Carrera
Max Vasin wrote: So, you need list of length 256 and then just use it as state of your PRNG. If you want to check list size you have to do it at runtime: f lst | length lst == 256 -> doWork | otherwise -> fail "length lst must be 256" Okay, thanks. Cheers, Daniel.

[Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Max Vasin
Daniel Carrera <[EMAIL PROTECTED]> writes: > Max Vasin wrote: > >> But why do you need that? Where do need to make an assumption about the size >> of the list? > > I'm implementing the RC4 algorithm, which requires a state array with > 256 elements containing the bytes from 0 to 255. As the algor

Re: [Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Daniel Carrera
Max Vasin wrote: But why do you need that? Where do need to make an assumption about the size of the list? I'm implementing the RC4 algorithm, which requires a state array with 256 elements containing the bytes from 0 to 255. As the algorithm progresses, the elements of the array get shuffled ar

[Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Max Vasin
Daniel Carrera <[EMAIL PROTECTED]> writes: > Hello, > > Right now I'm using type declarations like: > > f :: Int -> [Int] > > So f returns a list of Ints. > > Is there a way to tell Haskell that a list or array must have exactly > (say) 256 elements? I'd love to have Haskell make sure that the arr