Browse thread
[Caml-list] Q: Correct locations for macro camlp4 extensions
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Marcin 'Qrczak' Kowalczyk <qrczak@k...> |
| Subject: | Re: [Caml-list] Q: Correct locations for macro camlp4 extensions |
W li¶cie z pon, 23-08-2004, godz. 19:16 -0400, Michael Alexander Hamburg
napisa³:
> Another syntax construction that I might write up (which I'm not aware of
> in any programming language) would be something like
>
> (f _ x _ _ y) translates into (fun p1 p2 p3 -> f p1 x p2 p3 y)
My language Kogut uses this (along with _ in patterns as in other
functional languages). Note: these expressions are evaluated once,
not each time the function is applied.
http://kokogut.sourceforge.net/kogut.html
> When I have n lists of pairs to sort by the
> first element of the tuple, or some other function like that, it saves me
> a significant amount of programming effort to write
>
> # let (<-<<) f g a b = f (g a) (g b);;
> or
> # let sort_by g a b = sort (compare (g a) (g b));;
It may be better to perform Schwartzian transform: make a list of
(g x, x) pairs, sort it, and extract elements back. It applies g
O(N) rather than O(N log N) times.
Well, unless g is as simple as fst.
--
__("< Marcin Kowalczyk
\__/ qrczak@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
-------------------
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