[Haskell-beginners] index too large

Daniel Fischer daniel.is.fischer at web.de
Fri Nov 13 01:00:43 EST 2009


Am Freitag 13 November 2009 03:55:40 schrieb Nathan M. Holden:
> I've been working on a quick program that acts (vaguely) like a console,
> lets me type notes and outputs them in a .tex file. I figure it's not that
> complicated, but it uses a vaguely n-ary structure, so that I can have
> headers and sub-notes, which loos like:
>
> data Note = N {
>   nTitle  :: {Char},
>   nBody :: {Char},
>   nFormat :: Format,
>   subs :: [Note]
>
> | E [Char]
>
> Format's just a collection of preset formats, so I don't have to
> dynamically handle that (since I didn't need to for my uses).
>
> Anyways, for whatever reason, sometimes while adding notes, it sends me an
> error: Prelude.(!!): index too large

Obviously, sometimes you call list!!index with index > (length list - 1).
Are you aware that the indices are 0-based?
If it's not that, one would have to analyse the code, but it would be better to see more 
of it for that.





More information about the Beginners mailing list