* Re: [Caml-list] function polymorphic in number of arguments?
[not found] <20020917084045.46976.qmail@web11206.mail.yahoo.com>
@ 2002-09-17 15:23 ` Quetzalcoatl Bradley
0 siblings, 0 replies; 4+ messages in thread
From: Quetzalcoatl Bradley @ 2002-09-17 15:23 UTC (permalink / raw)
To: caml-list; +Cc: Noel Welsh
Actually I wanted to pass the same parameters to both g and h but your
solution is obvious and simple. if all the arguments of g and h are
curried then my generic function always has "one" argument, the tuple
of arguments to g and h, regardless of the size of the tuple.
So my function is
let f a b x = a x; b x;;
and a two argument "a" or "b" would be
let a x = match x with (i,j) -> print_string ("i" ^ "j");;
and I can call it e.g.
f a a ("z","x");;
Thanks,
Quetzalcoatl Bradley
qbradley@blackfen.com
On Tuesday, September 17, 2002, at 01:40 AM, Noel Welsh wrote:
> You can't have multiple arity functions or tuples in
> O'Caml, but you can curry the functions before calling
> them which is how I'd solve your problem. You want to
> write something like:
>
> fun f g h a1 a2 b1 b2 =
> g a1 a2 ; h b1 b2
>
> with varying numbers of a and b. Instead you can
> write:
>
>
> fun f g h a1 b1 =
> g a1; h b1
>
> and curry additional parameters when you call the
> function:
>
> f (g a2) (h a2)
>
> This gets the same effect. Alternatively you can use
> Scheme/Lisp which supports varying arity functions and
> has a handy apply function, for applying varying
> numbers of arguments to a function.
>
> Noel
> --- Quetzalcoatl Bradley <qbradley@blackfen.com>
> wrote:
>> Suppose all the parameters were curried. Unless I
>> could operate on
>> tuples like they were lists then I would still be in
>> the same boat. I
>> suppose if there was a tuple->list conversion
>> function I could achieve
>> the effect I desire. Is there such an operation?
>>
>> Thanks,
>>
>> Quetzalcoatl Bradley
>> qbradley@newheights.com
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
>
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Caml-list] mutually referencing compilation units
@ 2002-09-15 20:15 Henri Dubois-Ferriere
2002-09-16 3:44 ` [Caml-list] function polymorphic in number of arguments? Quetzalcoatl Bradley
0 siblings, 1 reply; 4+ messages in thread
From: Henri Dubois-Ferriere @ 2002-09-15 20:15 UTC (permalink / raw)
To: caml-list
hello,
given the banality i'm guessing this question has been asked before .. but
i couldn't find any clear statement related to this inthe archive.
So:
Is the fact that two mutually referencing units can't be compiled
supposed to be a Good Thing? It seems to be a consequence of the fact that
order of .cmo's is relevant, and when that design decision was made i
guess the restriction it entailed on mutual reference was not considered
to be a problem.
Thanks
Henri DF
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-09-18 18:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20020917084045.46976.qmail@web11206.mail.yahoo.com>
2002-09-17 15:23 ` [Caml-list] function polymorphic in number of arguments? Quetzalcoatl Bradley
2002-09-15 20:15 [Caml-list] mutually referencing compilation units Henri Dubois-Ferriere
2002-09-16 3:44 ` [Caml-list] function polymorphic in number of arguments? Quetzalcoatl Bradley
2002-09-16 12:19 ` Francois Thomasset
2002-09-16 12:24 ` Francois Thomasset
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox