[Haskell-cafe] Defining new operators

Rodrigo Queiro overdrigzed at gmail.com
Wed Aug 8 14:21:09 EDT 2007


In addition to creating a new operator, you can use the function as an
operator with ``, e.g.:
"1M" `dist` [[], ["2M"], ["2M, 3M"]] = [["1M"],["1M","2M"],["1M","2M, 3M"]]

Rodrigo

PS. Sorry if I sent this twice.

On 08/08/2007, rodrigo.bonifacio <rodrigo.bonifacio at uol.com.br> 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"]]
>
> Thanks in advance.
>
> Rodrigo.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list