Version française
Home     About     Download     Resources     Contact us    
Browse thread
mixing infix functions and the format4 types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Anil Madhavapeddy <anil@r...>
Subject: Re: [Caml-list] Re: mixing infix functions and the format4 types
On 30 Mar 2009, at 10:10, Zheng Li wrote:
>
> Is extra separators acceptable?
>
> # let ($) f x = f x;;
> val ( $ ) : ('a -> 'b) -> 'a -> 'b = <fun>
> # "foo" --- "%s %s %s" $ "bar1" $ "bar2" $ "bar3";;
> - : string = "foo: bar1 bar2 bar3"

Aha ... using the identity function like this works great, thanks!

-anil

>
> and, maybe in another way
>
> # let (%) fmt x = Printf.sprintf fmt x;;
> val ( % ) : ('a -> 'b, unit, string) format -> 'a -> 'b = <fun>
> # "%s %s %s" % "bar1" $ "bar2" $ "bar3";;
> - : string = "bar1 bar2 bar3"
>
> HTH.
> --
> Zheng
>
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs