[Haskell-beginners] ignature for a list of a set length
martin.tomko at geo.uzh.ch
Tue Sep 28 11:39:50 EDT 2010
I like this suggestion, I will give it a go!
thanks, and also for the catMaybes function, I needed something like
that some days ago.
On 9/28/2010 5:20 PM, edgar klerks wrote:
> I think it is simpler to use the Maybe type for this. If you only
> search for ternary relations, you can write a function, which only
> converts a list to a 3-tuple if it is of length three and otherwise it
> returns nothing. Then with catMaybes :: [Maybe a] -> [a], you can
> convert it back to a list with only 3-tuples.
> import Data.Maybe
> getLengthThree = catMaybes . fmap toTup
> where toTup (x:y:z:) = Just (x,y,z)
> toTup _ = Nothing
Postdoctoral Research Assistant
Geographic Information Systems Division
Department of Geography
University of Zurich - Irchel
CH-8057 Zurich, Switzerland
email: martin.tomko at geo.uzh.ch
mob: +41-788 629 558
More information about the Beginners