diff options
author | Louis Pilfold <louis@lpil.uk> | 2024-03-17 12:25:28 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2024-03-17 12:25:28 +0000 |
commit | 7a15388249b67a0119351f12b6e94d9777fbd10c (patch) | |
tree | e2f04d8e0e1ee7ac0aa8b3c782afb9c9bf7fcfbd /src | |
parent | 30129692d1eeb6a898cbd005b8292bf3230e7e51 (diff) | |
download | gleam_stdlib-7a15388249b67a0119351f12b6e94d9777fbd10c.tar.gz gleam_stdlib-7a15388249b67a0119351f12b6e94d9777fbd10c.zip |
Deprecate list.at
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/list.gleam | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index d495dda..3b7aebe 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -22,11 +22,11 @@ //// ``` //// -import gleam/int +import gleam/dict.{type Dict} import gleam/float +import gleam/int import gleam/order.{type Order} import gleam/pair -import gleam/dict.{type Dict} /// Counts the number of elements in a given list. /// @@ -1115,6 +1115,12 @@ pub fn intersperse(list: List(a), with elem: a) -> List(a) { /// // -> Error(Nil) /// ``` /// +@deprecated(" + +Gleam lists are immutable linked lists, so indexing into them is a slow operation that must traverse the list. + +In functional programming it is very rare to use indexing, so if you are using indexing then a different algorithm or a different data structure is likely more appropriate. +") pub fn at(in list: List(a), get index: Int) -> Result(a, Nil) { case index >= 0 { True -> |