LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-20-2009, 07:50 AM   #1
satori@sanitarium
LQ Newbie
 
Registered: Feb 2008
Posts: 9

Rep: Reputation: 0
haskell question


I just started to learn haskell and I just came to my first wtf moment.

I'm trying to do something like this:

calling:
foo 3 [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4]

returns:
[[1,2,3],[2,4,1,6,3],[2,3]]

but i have no idea how to put something into a sublist.

How to make a list of sublists out of a list, whether they be a list of numbers or a string.

TX in advance.
 
Old 10-20-2009, 05:35 PM   #2
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 60
I don't know a ton about Haskell, but before anything else, can you please clarify what you want to happen here?

What determines which elements (or how many elements) end up in which of the sub-arrays? Why did the values 5, 2, 5, 2, 1, 6, 4 simply drop off the result? What's the logic of the function? As an example of what I mean, both take and drop operate on lists: take selects the first n items of the list and drop removes the first n items.

Code:
Prelude> take 5[1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5]
Prelude> drop 5[1,2,3,4,5,6,7,8,9,10]
[6,7,8,9,10]
Prelude> drop 2[1,2,3,4,5,6,7,8,9,10]
[3,4,5,6,7,8,9,10]
What is the foo function supposed to do exactly?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Rant: Who actually likes Haskell? Berticus General 5 10-27-2008 01:53 PM
LXer: Programming in Haskell LXer Syndicated Linux News 0 05-03-2007 04:47 PM
LXer: Translate the Haskell into English Manually, Part II LXer Syndicated Linux News 0 08-05-2006 06:21 PM
LXer: Translate Haskell into English Manually LXer Syndicated Linux News 0 06-21-2006 11:12 PM
Programming Haskell in Slackware 10.2 ivoencarnacao Slackware 4 10-08-2005 10:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration