[Haskell-cafe] How to get subset of a list?
Huazhi (Hank) Gong
hankgong at nm.gist.ac.kr
Thu Nov 30 21:04:10 EST 2006
Thanks, it make sense here.
However, like I want to choose s[1,3,6,10] or something like this. Are there
some straightforward function or operator for doing this job? The !!
operator in haskell seems does not support multiple indecies.
Stefan O wrote:
> On Thu, Nov 30, 2006 at 05:47:43PM -0800, Huazhi (Hank) Gong wrote:
>> Like given a string list s="This is the string I want to test", I want to
>> the substring. In ruby or other language, it's simple like s[2..10], but
>> to do it in Haskell?
> Use take and drop, from the Prelude:
> (ghci session)
> Prelude> "Hello world"
> "Hello world"
> Prelude> drop 3 "Hello world"
> "lo world"
> Prelude> take 7 (drop 3 "Hello world")
> "lo worl"
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
View this message in context: http://www.nabble.com/How-to-get-subset-of-a-list--tf2735647.html#a7632145
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe