From 571803ae686c226ad1db4c54c7a6d2b579b9ba9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Wed, 28 Nov 2012 16:15:26 +0100 Subject: erts: Document insert_element and delete_element Document new BIFs: * erlang:insert_element/3 * erlang:delete_element/2 --- erts/doc/src/erlang.xml | 34 ++++++++++++++++++++++++++++++++++ erts/preloaded/src/erlang.erl | 19 +++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index 1a97a84b42..2faa46d760 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -626,6 +626,22 @@ false {more,6} + + + + Delete element at index in a tuple + 1..tuple_size(Tuple1) + +

+ Returns a new tuple with element at Index removed from + tuple Tuple1. +

+
+> erlang:delete_element(2, {one, two, three}).
+{one,three}
+
+
+ Make the current code for a module old @@ -1361,6 +1377,24 @@ os_prompt% when the process wakes up.

+ + + + Insert an element at index in a tuple + 1..tuple_size(Tuple1) + 1 + +

+ Returns a new tuple with element Term insert at position + Index in tuple Tuple1. + All elements from position Index and upwards are subsequently + pushed one step higher in the new tuple Tuple2. +

+
+> erlang:insert_element(2, {one, two, three}, new).
+{one,new,two,three}
+
+
+ Text representation of an integer diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index 51a190b095..739fdde10a 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -79,6 +79,7 @@ -export([bump_reductions/1, byte_size/1, call_on_load_function/1]). -export([cancel_timer/1, check_old_code/1, check_process_code/2, crc32/1]). -export([crc32/2, crc32_combine/3, date/0, decode_packet/3]). +-export([delete_element/2]). -export([delete_module/1, demonitor/1, demonitor/2, display/1]). -export([display_nl/0, display_string/1, dist_exit/3, erase/0, erase/1]). -export([error/1, error/2, exit/1, exit/2, external_size/1]). @@ -88,6 +89,7 @@ -export([garbage_collect_message_area/0, get/0, get/1, get_keys/1]). -export([get_module_info/1, get_stacktrace/0, group_leader/0]). -export([group_leader/2, halt/0, halt/1, halt/2, hash/2, hibernate/3]). +-export([insert_element/3]). -export([integer_to_list/1, iolist_size/1, iolist_to_binary/1]). -export([is_alive/0, is_builtin/3, is_process_alive/1, length/1, link/1]). -export([list_to_atom/1, list_to_binary/1, list_to_bitstr/1]). @@ -529,6 +531,14 @@ date() -> decode_packet(_Type, _Bin, _Options) -> erlang:nif_error(undefined). +%% delete_element/2 +-spec erlang:delete_element(Index, Tuple1) -> Tuple2 when + Index :: pos_integer(), + Tuple1 :: tuple(), + Tuple2 :: tuple(). +delete_element(_Index, _Tuple1) -> + erlang:nif_error(undefined). + %% delete_module/1 -spec delete_module(Module) -> true | undefined when Module :: module(). @@ -820,6 +830,15 @@ hash(_Term, _Range) -> hibernate(_Module, _Function, _Args) -> erlang:nif_error(undefined). +%% insert_element/3 +-spec erlang:insert_element(Index, Tuple1, Term) -> Tuple2 when + Index :: pos_integer(), + Tuple1 :: tuple(), + Tuple2 :: tuple(), + Term :: term(). +insert_element(_Index, _Tuple1, _Term) -> + erlang:nif_error(undefined). + %% integer_to_list/1 -spec integer_to_list(Integer) -> string() when Integer :: integer(). -- cgit v1.2.3