Commit Graph

42 Commits (master)

Author SHA1 Message Date
Jeremy Yallop 0aa72dd034 Add some injectivity annotations to the standard library. 2020-07-18 15:50:42 +01:00
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
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01: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
alainfrisch 4ea470feb1 Fix, add since tag. 2017-02-28 14:20:47 +01:00
Sébastien Briais 0c9de3c93a Modify API of update. 2017-02-28 14:11:45 +01:00
Sébastien Briais 84b03d9e6d Define Map.update. 2017-02-28 14:11:45 +01:00
Albin Coquereau 7ce080e102 Change Map (private) type to inline records (#1018) 2017-02-24 15:30:02 +01: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
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
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
alainfrisch 324ed6b711 PR#6449: add Map.union. 2016-01-04 18:21:18 +01:00
iguer d689a686b9 Map.add x y m returns the original map if x is already bound to a value that is physically equal to y in m 2015-11-22 18:29:16 +01:00
iguer 37159fbc42 Map.filter returns the original map when the given predicate satisfies all the bindings of the map 2015-11-22 18:29:16 +01:00
iguer 81ca324ef3 Map.remove returns the original map when the binding to be removed is not present in the map 2015-11-22 18:29:15 +01:00
Damien Doligez c63f9e0957 fix a few problems with whitespace and over-long lines
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13393 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-03-09 22:38:52 +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
Jonathan Protzenko bc8d8e957e Fix #5171: Map: avoid unnecessary uses of the user-provided comparison function in [join].
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11955 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-12-23 20:54:57 +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
Alain Frisch 66092ce6ff Extend Map with functions from Set.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10468 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-25 13:29:43 +00:00
Alain Frisch e671780b01 Fix PR#4012: Map.map and Map.mapi do not conform to specification.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10465 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-25 11:22:14 +00:00
Damien Doligez a4a3c10e70 fusion des modifs de 3.08.4
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7019 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2005-08-13 20:59:37 +00:00
Damien Doligez 8397a6a5af suppression de variables inutiles
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6697 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-11-25 13:28:27 +00:00
Xavier Leroy 32077394fe Ajout Map.is_empty, Map.compare, Map.equal
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6250 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2004-04-23 10:01:34 +00:00
Xavier Leroy d60708263e Probleme d'equilibrage dans remove (PR#1720)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5610 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2003-06-23 07:28:54 +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
Jacques Garrigue 96e7b2baa3 add variance annotation
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3409 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2001-02-12 23:46:18 +00:00
Xavier Leroy 5cdfd65c27 Ajout de mapi
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2835 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2000-02-21 18:12:16 +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 a5eb7789fd Revu le module Buffer.
Utilise Buffer dans Printf.sprintf; ajout Printf.bprintf.
Ajout Map.mem.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2309 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1999-02-25 10:26:38 +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
Xavier Leroy 2df80222b9 Typo dans message d'erreur
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1722 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-10-15 09:21:03 +00:00
Jérôme Vouillon 51e175d3bc Ajout de la fonction [map].
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1520 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1997-05-10 15:38:44 +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 cb1ae6ffdf Ajout de Map.remove.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@739 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1996-04-04 15:57:00 +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 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