From 76acbf9bb656b27ed21d4327d6e0a9b094211ce0 Mon Sep 17 00:00:00 2001 From: John Gabriele Date: Sat, 24 Jul 2021 18:44:49 -0400 Subject: [PATCH] Clarify docs on take and drop functions Pass in indexed and bytes, return tuples and strings, respectively. --- src/boot/boot.janet | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index d7e1bbe2..45377a5e 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -1027,7 +1027,7 @@ ret) (defn take - "Take first n elements in an indexed type. Returns new indexed instance." + "Take the first n elements of an indexed or bytes type. Returns a new tuple or string, respectively." [n ind] (def use-str (bytes? ind)) (def f (if use-str string/slice tuple/slice)) @@ -1038,7 +1038,7 @@ (f ind 0 end)) (defn take-until - "Same as (take-while (complement pred) ind)." + "Same as `(take-while (complement pred) ind)`." [pred ind] (def use-str (bytes? ind)) (def f (if use-str string/slice tuple/slice)) @@ -1048,13 +1048,14 @@ (f ind 0 end)) (defn take-while - `Given a predicate, take only elements from an indexed type that satisfy - the predicate, and abort on first failure. Returns a new array.` + `Given a predicate, take only elements from an indexed or bytes type that satisfy + the predicate, and abort on first failure. Returns a new tuple or string, respectively.` [pred ind] (take-until (complement pred) ind)) (defn drop - "Drop first n elements in an indexed type. Returns new indexed instance." + ``Drop the first n elements in an indexed or bytes type. Returns a new tuple or string + instance, respectively.`` [n ind] (def use-str (bytes? ind)) (def f (if use-str string/slice tuple/slice)) @@ -1065,7 +1066,7 @@ (f ind start -1)) (defn drop-until - "Same as (drop-while (complement pred) ind)." + "Same as `(drop-while (complement pred) ind)`." [pred ind] (def use-str (bytes? ind)) (def f (if use-str string/slice tuple/slice)) @@ -1075,8 +1076,8 @@ (f ind start)) (defn drop-while - `Given a predicate, remove elements from an indexed type that satisfy - the predicate, and abort on first failure. Returns a new array.` + `Given a predicate, remove elements from an indexed or bytes type that satisfy + the predicate, and abort on first failure. Returns a new tuple or string, respectively.` [pred ind] (drop-until (complement pred) ind))