From 7a15388249b67a0119351f12b6e94d9777fbd10c Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Sun, 17 Mar 2024 12:25:28 +0000 Subject: Deprecate list.at --- src/gleam/list.gleam | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') 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 -> -- cgit v1.2.3