tags:

views:

149

answers:

2

I am trying to walk through the functions in Data.List of the Haskell stardard library and get an error when trying "permutations". What am I missing here? Thanks.

Prelude> map (\b-> b*b) [1,2,3]
[1,4,9]
Prelude> permutations "abc"

<interactive>:1:0: Not in scope: `permutations'
+4  A: 

That library page you linked to is for the base libraries version 4 which come with GHC version 6.10. Are you sure you are running GHC 6.10? If you are running the previous version 6.8 then there will not be a permutations function in Data.List.

Matthew Manela
+7  A: 

Data.List.permutations was released in GHC 6.10.1. Chances are you have an earlier version. But if you did have the correct version, you would have to load the Data.List module like this:

Prelude> :m +Data.List
Prelude Data.List> permutations "abc"
["abc","bac","cba","bca","cab","acb"]
Mark Rushakoff