Commit Graph

39 Commits (master)

Author SHA1 Message Date
Sébastien Briais f52fdc2068
Define to_rev_seq in Set and Map module (#9075) 2020-05-15 17:38:45 +02:00
Gabriel Scherer 1cd6e4451f Map.filter_map and Set.filter_map 2020-03-31 15:01:41 +02:00
Nicolás Ojeda Bär 8ec445eb1c Add Set.Make(_).disjoint 2018-08-10 16:23:15 +02:00
Simon Cruanes df80f34a92 Stdlib functional iterators (#1002)
* add `Seq` module, expose iterator conversions in most containers

* small typo

* typo

* change order of arguments for `{Map,Set}.add_seq`

* watch for max string length in `Bytes.of_seq`

* wip: make it build again

* Fix dependency

Sys needs to be linked before Bytes in stdlib.

* Update threads/stdlib.ml

* Update stdlib_no_prefixed/.depend

* fix inconsistencies with label modules

* update testsuite to work with seq

* update change file

* small change in `Hashtbl.to_seq`, capturing only the underlying array

* add some documentation to seq.mli

* revert to good ol' module type names for hashtables

* fix test

* change style of comments in seq.mli

* follow some demands in review of GPR #1002

* some fixes for #1002

* add Seq-related functions to Ephemeron

* add some comments on `Hashtbl.of_seq`

* add more tests for `Hashtbl.{to,of}_seq`

* fix bug in `Ephemeron.to_seq`

* Update Changes
2018-03-16 18:25:10 +01:00
Albin Coquereau f05f81ba20 Change Set (private) type to inline records (#1119)
* Change Set (private) type to inline records

* Changes for GPR#1119

* cosmetic change

* Changes edited
2017-04-18 16:59:05 +02:00
Gabriel de Perthuis bf4b142586 [Stdlib] Implement find_first, find_last for maps and sets (#869)
Finds the first/last binding where the key satisfies a monotonic
predicate.

Addresses #665, supersedes #868.
Thanks @alainfrisch for the idea and most of the implementation.
2016-11-12 22:47:46 +01:00
Gabriel Scherer 8972bd0693 PR#7403: fix a bug in Set.map (new in 4.04.0)
(cherry-pick from the 4.04 branch)
2016-11-07 14:51:20 -05:00
Alain Frisch 69263a9893 Option-returning variants of stdlib functions (#885)
Provide an xxx_opt alternative for functions raising Not_found
and many instances of Failure/Invalid_arg.

The only exception is the rarely used Buffer.add_substitute, where
the [Not_found] can really be interpreted as an error condition.

Most new functions are implemented directly (instead of wrapping the
raising version).  This is for performance reasons and also to avoid
destroying the stacktrace (if the function is used in an exception
handler).  One could instead implement the raising versions on top of
the new functions, but there might be a small penalty.
2016-11-07 16:11:35 +00:00
Gabriel Scherer a55b520a58 PR#6279: add Set.map 2016-04-25 08:47:16 -04:00
Alain Frisch 8557a86477 Also enable more warnings in stdlib/ and fix them. 2016-03-15 22:47:26 +01:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Alain Frisch b94c4b840f GPR#174: ensure that Set.remove and Set.filter return the original set (physically) when no change is required. Also avoid allocations in this case. Similar to what had been done for Set.add in #6645.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16080 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-05-05 16:08:00 +00:00
Alain Frisch 30bb2c39d8 #6645: Set.add returns the original set when the element to be added is already in it, and document this invariant. Also guarantee that in that case, Set.add doesn't allocate (but do not document it for now).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15966 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-26 09:28:59 +00:00
Damien Doligez 7303ac34ca fix some of the whitespace problems in the source
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14582 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-04-12 10:17:02 +00:00
Alain Frisch edb771d22b #4986. Add two common operations: List.sort_uniq (more efficient that sorting then removing duplicates) and Set.of_list (more efficient than folding Set.add over the list).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13876 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-07-09 11:01:42 +00:00
Alain Frisch 706f815450 #5864: add a find operation to Set.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13211 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-01-08 09:01:02 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Gabriel Scherer e3d8281790 Ensure that {Set,Map}.{filter,partition} call their functional argument
in the user-expected left-to-right evaluation order.

This is a cosmetics change but users usually expect the
mapping/filtering functions to be called in increasing key order. As
the order for filter and partition changed recently anyway (commit
r12026), it makes sense to "fix" it now.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12509 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-05-30 11:28:28 +00:00
Xavier Leroy ee95e9fd91 More efficient implementation of {Set,Map}.{filter,partition}
Optimize Set.join just like Map.join was recently.
Added some tests for Set and Map.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12026 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-01-16 09:03:16 +00:00
Damien Doligez 3b507dd1aa renaming of Objective Caml to OCaml and cleanup of copyright headers
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11156 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-27 14:17:02 +00:00
Damien Doligez 7519fe8f6b fusion des bugfixes de 3.08.2
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6694 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-11-25 00:06:06 +00:00
Xavier Leroy 0d71c73c37 Meilleure implementation de Set.compare. Revu doc de Set.split.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6251 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-04-23 10:01:54 +00:00
Basile Starynkevitch 4041c97364 added split in the result of Set.Make
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6202 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-04-14 11:10:22 +00:00
Xavier Leroy 38558879cc Problemes d'equilibrage dans join et remove (PR#1717,PR#1720)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5609 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-06-23 07:28:34 +00:00
Xavier Leroy 7501784c80 MAJ en-tetes pour mentionner la 'special exception' sur la LGPL
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4144 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-12-07 13:41:02 +00:00
Pierre Weis 2116da4220 Getting rid of obsolete boolean operators & and or
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3359 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2000-12-28 13:07:42 +00:00
Xavier Leroy 63f7a020fe Ajout iterateurs for_all, exists, filter, partition
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3073 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2000-04-13 12:16:26 +00:00
Xavier Leroy cc0f32b054 Changement de la licence
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2553 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-11-17 18:59:06 +00:00
Xavier Leroy c1eec2c119 Ajout de Set.singleton, optimisation de Set.union
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2006 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1998-07-02 09:48:14 +00:00
Xavier Leroy 95933de17c Corrections mineures sur la documentation
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1933 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1998-04-27 09:55:50 +00:00
Damien Doligez b8ccccff49 Makefiles: fix disparition de weak.cmo
Changement de type des fonctions iter


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1747 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-10-31 12:59:29 +00:00
Jérôme Vouillon 910aafd580 Ajout de la fonction [subset].
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1519 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-05-10 15:38:17 +00:00
Xavier Leroy 2301d778e7 Renommage en Objective Caml
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@782 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1996-04-30 14:53:58 +00:00
Jérôme Vouillon 7974a9d8b1 Extension objets.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@756 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1996-04-22 11:15:41 +00:00
Xavier Leroy db7e46b25c Introduction de "S with module ... = ..."
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@306 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-10-01 13:39:43 +00:00
Xavier Leroy e4066357b1 Ajout des notices de copyright
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@195 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-08-09 15:06:35 +00:00
Xavier Leroy 41bd2b6153 Fermetures representees en un seul bloc
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@49 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-06-22 10:11:18 +00:00
Xavier Leroy b9a3348b49 Suppression de baltree, dont le code est maintenant integre
directement dans set.
Creation de map.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@19 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-05-30 13:33:57 +00:00
Xavier Leroy 61bd8ace6b Passage a la version bootstrappee (franchissement du Rubicon)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1995-05-04 10:15:53 +00:00