[Haskell-cafe] Defining new operators

Stefan O'Rear stefanor at cox.net
Wed Aug 8 14:17:51 EDT 2007


On Wed, Aug 08, 2007 at 03:14:43PM -0300, rodrigo.bonifacio wrote:
> Hello,
> 
> I have created the following function:
> 
> dist :: String -> [[String]] -> [[String]]
> dist x  y = [ x:e | e<-y ]
> 
> eg.:
> 
> dist "1M" [[], ["2M"], ["2M, 3M"]] = [["1M"],["1M","2M"],["1M","2M, 3M"]]
> 
> How can I create an operator that perform the same function as dist? I want to write something like:
> 
> "1M" ++ [[], ["2M"], ["2M", "3M"]]

(+++) :: String -> [[String]] -> [[String]]
x +++ y = [ x:e | e<-y ]

"1M" +++ [[], ["2M"], ["2M", "3M"]]

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070808/247a2199/attachment.bin


More information about the Haskell-Cafe mailing list