List Info

Thread: "ocaml_beginners"::[] Haskell has: $, does OCaml have something similiar?




"ocaml_beginners"::[] Haskell has: $, does OCaml have something similiar?
country flaguser name
United Kingdom
2007-08-19 08:23:21

Hello!

Haskell has an operator $, which allows one to write
this:

func1(func2 a b (func3 c))

like this:

func1 $ func2 a b $ func c

Does OCaml have a operator like that?

__________________________________________________________
Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling.
Sök och jämför hos Yahoo! Shopping.
http://shopping.yahoo.se/c-100015813-bredband.html?partnerId=96914325

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] Haskell has: $, does OCaml have something similiar?
country flaguser name
United Kingdom
2007-08-20 03:16:42

On Sunday 19 August 2007 14:23:21 Leif D wrote:
> Hello!
>
> Haskell has an operator $, which allows one to write
> this:
>
> func1(func2 a b (func3 c))
>
> like this:
>
> func1 $ func2 a b $ func c
>
> Does OCaml have a operator like that?

Not built in. You can define your own operators, of course, and there are a
wide variety of standard operators from many languages. Mathematica uses as
an equivalent to Haskell's $, and that is OCaml-compatible because is right
associative in OCaml whereas $ is left associative:

# let ( ) f x = f x;;
val ( ) : ('a -> 'b) -> 'a -> 'b = <fun>;
# let f f1 f2 f3 a b c = f1 f2 a b f3 c;;
val f :
('a -> 'b) -> ('c -> 'd -> 'e -> 'a) -> ('f -> 'e) -> 'c -> 'd -> 'f -> 'b =
<fun>;

There are also operators in F# that do similar things <<, >> and |>. With an
infinite number of ways to write combinators I think it makes sense to write
your own when you need them.

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )