From 88602529a9dc2517a94435b3f5449aae8cf88de4 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:26:14 +0200 Subject: [PATCH 01/24] Collections/drop: change function description --- src/library/Collections.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 066ee381a7..293f3fd0e0 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -372,7 +372,7 @@ proc defineSymbols*() = alias = unaliased, op = opNop, rule = PrefixPrecedence, - description = "drop first *number* of elements from given collection and return the remaining ones", + description = "remove first item from given collection", args = { "collection": {String, Block, Literal}, "number" : {Integer} From 881720a60558864f370e4bd689a70b987ed54de3 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:34:28 +0200 Subject: [PATCH 02/24] Collections/drop: remove 2nd `number` parameter (it's not going to take a second one) --- src/library/Collections.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 293f3fd0e0..250b73c48d 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -374,8 +374,7 @@ proc defineSymbols*() = rule = PrefixPrecedence, description = "remove first item from given collection", args = { - "collection": {String, Block, Literal}, - "number" : {Integer} + "collection": {String, Block, Literal} }, attrs = NoAttrs, returns = {String, Block, Nothing}, From 3f7a6214a1abea6a22ef57779478955accb5ba21 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:35:19 +0200 Subject: [PATCH 03/24] Collections/drop: added a `.times:` attribute (exactly like its twin, `chop`) --- src/library/Collections.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 250b73c48d..acb25bd930 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -376,7 +376,9 @@ proc defineSymbols*() = args = { "collection": {String, Block, Literal} }, - attrs = NoAttrs, + attrs = { + "times" : ({Integer}, "remove multiple items") + }, returns = {String, Block, Nothing}, example = """ str: "some text" From 30b44350fe862dc1d7fb78468b66f5d488c394e3 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:36:51 +0200 Subject: [PATCH 04/24] Collections/drop: updated implementation --- src/library/Collections.nim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index acb25bd930..13146ed2d8 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -393,15 +393,20 @@ proc defineSymbols*() = drop [1 2 3] 4 ; => [] """: #======================================================= + + var times = 1 + + if checkAttr("times"): + times = aTimes.i template numberInRange(container: untyped): untyped = - container.len >= abs(y.i) + container.len >= abs(times) template drop(container: untyped): untyped = - if 0 < y.i: - container[y.i..^1] + if 0 < times: + container[times..^1] else: - container[0.. container.high - abs(y.i)] + container[0.. container.high - abs(times)] if x.kind == Literal: ensureInPlace() From 4ea3b4b827e7784befdb1ea28d0d6cb7c7a6683c Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:37:05 +0200 Subject: [PATCH 05/24] minor edit --- src/library/Collections.nim | 1 - 1 file changed, 1 deletion(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 13146ed2d8..7a50a3f80e 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -393,7 +393,6 @@ proc defineSymbols*() = drop [1 2 3] 4 ; => [] """: #======================================================= - var times = 1 if checkAttr("times"): From 488b93fbb5975ec1cfd0ef5d3bc8538a608af9b1 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:38:12 +0200 Subject: [PATCH 06/24] build update --- version/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/build b/version/build index 14e963ae25..dca5ef64f9 100644 --- a/version/build +++ b/version/build @@ -1 +1 @@ -975 \ No newline at end of file +976 \ No newline at end of file From e3eab12cb195e8519e4d1601c65894796dc63b15 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:48:04 +0200 Subject: [PATCH 07/24] updated unit-test --- tests/unittests/lib.collections.art | 80 ++++++++++++++--------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/unittests/lib.collections.art b/tests/unittests/lib.collections.art index 1b5afe878d..b59d6b5c18 100644 --- a/tests/unittests/lib.collections.art +++ b/tests/unittests/lib.collections.art @@ -481,26 +481,26 @@ do [ topic "drop - :string < :string :string" do [ - ensure -> "art" = drop "art" 0 + ensure -> "art" = drop.times:0 "art" passed - ensure -> "rt" = drop "art" 1 - ensure -> "t" = drop "art" 2 + ensure -> "rt" = drop "art" + ensure -> "t" = drop.times:2 "art" passed - ensure -> "" = drop "art" 3 - ensure -> "" = drop "art" 4 + ensure -> "" = drop.times:3 "art" + ensure -> "" = drop.times:4 "art" passed - ensure -> "art" = drop "art" neg 0 + ensure -> "art" = drop.times: neg 0 "art" passed - ensure -> "ar" = drop "art" neg 1 - ensure -> "a" = drop "art" neg 2 + ensure -> "ar" = drop.times: neg 1 "art" + ensure -> "a" = drop.times: neg 2 "art" passed - ensure -> "" = drop "art" neg 3 - ensure -> "" = drop "art" neg 4 + ensure -> "" = drop.times: neg 3 "art" + ensure -> "" = drop.times: neg 4 "art" passed ] @@ -508,35 +508,35 @@ do [ topic "drop - :string < :string (literal) :string" do [ - a: "art", drop 'a 0 + a: "art", drop.times:0 'a ensure -> "art" = a passed - a: "art", drop 'a 1 + a: "art", drop 'a ensure -> "rt" = a - a: "art", drop 'a 2 + a: "art", drop.times:2 'a ensure -> "t" = a passed - a: "art", drop 'a 3 + a: "art", drop.times:3 'a ensure -> "" = a - a: "art", drop 'a 4 + a: "art", drop.times:4 'a ensure -> "" = a passed - a: "art", drop 'a neg 0 + a: "art", drop.times: neg 0 'a ensure -> "art" = a passed - a: "art", drop 'a neg 1 + a: "art", drop.times: neg 1 'a ensure -> "ar" = a - a: "art", drop 'a neg 2 + a: "art", drop.times: neg 2 'a ensure -> "a" = a passed - a: "art", drop 'a neg 3 + a: "art", drop.times: neg 3 'a ensure -> "" = a - a: "art", drop 'a neg 4 + a: "art", drop.times: neg 4 'a ensure -> "" = a passed @@ -545,26 +545,26 @@ do [ topic "drop - :block < :block :block" do [ - ensure -> [a b c] = drop [a b c] 0 + ensure -> [a b c] = drop.times:0 [a b c] passed - ensure -> [b c] = drop [a b c] 1 - ensure -> [c] = drop [a b c] 2 + ensure -> [b c] = drop [a b c] + ensure -> [c] = drop.times:2 [a b c] passed - ensure -> [] = drop [a b c] 3 - ensure -> [] = drop [a b c] 4 + ensure -> [] = drop.times:3 [a b c] + ensure -> [] = drop.times:4 [a b c] passed - ensure -> [a b c] = drop [a b c] neg 0 + ensure -> [a b c] = drop.times: neg 0 [a b c] passed - ensure -> [a b] = drop [a b c] neg 1 - ensure -> [a] = drop [a b c] neg 2 + ensure -> [a b] = drop.times: neg 1 [a b c] + ensure -> [a] = drop.times: neg 2 [a b c] passed - ensure -> [] = drop [a b c] neg 3 - ensure -> [] = drop [a b c] neg 4 + ensure -> [] = drop.times: neg 3 [a b c] + ensure -> [] = drop.times: neg 4 [a b c] passed ] @@ -572,35 +572,35 @@ do [ topic "drop - :block < :block (literal) :block" do [ - a: [a b c], drop 'a 0 + a: [a b c], drop.times:0 'a ensure -> [a b c] = a passed - a: [a b c], drop 'a 1 + a: [a b c], drop 'a ensure -> [b c] = a - a: [a b c], drop 'a 2 + a: [a b c], drop.times:2 'a ensure -> [c] = a passed - a: [a b c], drop 'a 3 + a: [a b c], drop.times:3 'a ensure -> [] = a - a: [a b c], drop 'a 4 + a: [a b c], drop.times:4 'a ensure -> [] = a passed - a: [a b c], drop 'a neg 0 + a: [a b c], drop.times: neg 0 'a ensure -> [a b c] = a passed - a: [a b c], drop 'a neg 1 + a: [a b c], drop.times: neg 1 'a ensure -> [a b] = a - a: [a b c], drop 'a neg 2 + a: [a b c], drop.times: neg 2 'a ensure -> [a] = a passed - a: [a b c], drop 'a neg 3 + a: [a b c], drop.times: neg 3 'a ensure -> [] = a - a: [a b c], drop 'a neg 4 + a: [a b c], drop.times: neg 4 'a ensure -> [] = a passed From 6f4315b664be58c91ba2b57155abbdee3cda5997 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:50:39 +0200 Subject: [PATCH 08/24] updated RC example "Forward difference" --- examples/rosetta/forward difference.art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rosetta/forward difference.art b/examples/rosetta/forward difference.art index 022f6cf0f9..9c471558cc 100644 --- a/examples/rosetta/forward difference.art +++ b/examples/rosetta/forward difference.art @@ -9,7 +9,7 @@ vsub: function [u v][ differences: function [block][ order: attr "order" if order = null -> order: 1 - loop 1..order 'n -> block: vsub block drop block 1 + loop 1..order 'n -> block: vsub block drop block return block ] From b790049950f202954d9da1ea7952678b0479f165 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:51:44 +0200 Subject: [PATCH 09/24] updated RC example "Iccanobif primes" --- examples/rosetta/iccanobif primes.art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rosetta/iccanobif primes.art b/examples/rosetta/iccanobif primes.art index 6158ca201e..d0514fd8c8 100644 --- a/examples/rosetta/iccanobif primes.art +++ b/examples/rosetta/iccanobif primes.art @@ -3,7 +3,7 @@ summarize: function [n :string][ ;; description: « returns a summary of a numeric string s: size n - if s > 20 -> n: ((take n 10)++"...")++drop n s-10 + if s > 20 -> n: ((take n 10)++"...")++drop.times:s-10 n n ++ ~" (|s| digits)" ] From 646937b74d72d2c15db48ed0475121fc41871724 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:52:43 +0200 Subject: [PATCH 10/24] updated RC example "Largest difference between adjacent primes" --- examples/rosetta/largest difference between adjacent primes.art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rosetta/largest difference between adjacent primes.art b/examples/rosetta/largest difference between adjacent primes.art index b01a087390..dea8f48a56 100644 --- a/examples/rosetta/largest difference between adjacent primes.art +++ b/examples/rosetta/largest difference between adjacent primes.art @@ -2,7 +2,7 @@ primes: select range.step:2 3 1e6 => prime? -pair: couple primes drop primes 1 +pair: couple primes drop primes | maximum'p -> p\1 - p\0 | <= From 70fd2aad168608cf19cf972db4cb9afae8d54d50 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:53:36 +0200 Subject: [PATCH 11/24] updated RC example "Quaternion type" --- examples/rosetta/quaternion type.art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rosetta/quaternion type.art b/examples/rosetta/quaternion type.art index b2c1701a29..119856d000 100644 --- a/examples/rosetta/quaternion type.art +++ b/examples/rosetta/quaternion type.art @@ -4,7 +4,7 @@ qnorm: $ => [sqrt fold & [x y] -> x + y*y] qneg: $ => [map & => neg] -qconj: $[q] [@[q\0] ++ qneg drop q 1] +qconj: $[q] [@[q\0] ++ qneg drop q] qaddr: function [q r][ [a b c d]: q From 174e10e07c6e2606b4b23d44d2677aedb28aec80 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:55:43 +0200 Subject: [PATCH 12/24] updated RC example "Substring/Top and tail" --- examples/rosetta/substring - top and tail.art | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/rosetta/substring - top and tail.art b/examples/rosetta/substring - top and tail.art index 141d7ca831..e2058582c8 100644 --- a/examples/rosetta/substring - top and tail.art +++ b/examples/rosetta/substring - top and tail.art @@ -2,12 +2,12 @@ knight: "knight" socks: "socks" brooms: "brooms" -print drop knight 1 ; strip first character +print drop knight ; strip first character print slice knight 1 (size knight)-1 ; alternate way to strip first character print chop socks ; strip last character print take socks (size socks)-1 ; alternate way to strip last character print slice socks 0 (size socks)-2 ; yet another way to strip last character -print chop drop brooms 1 ; strip both first and last characters +print chop drop brooms ; strip both first and last characters print slice brooms 1 (size brooms)-2 ; alternate way to strip both first and last characters \ No newline at end of file From 73bd8286d3e8b1b323d8af649c8995ed5431f496 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:56:52 +0200 Subject: [PATCH 13/24] updated RC example "The Name Game" --- examples/rosetta/the name game.art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rosetta/the name game.art b/examples/rosetta/the name game.art index 500a55dcde..0dd86276cb 100644 --- a/examples/rosetta/the name game.art +++ b/examples/rosetta/the name game.art @@ -3,7 +3,7 @@ nameGame: function [Name][ L: take Name 1 name: lower Name - unless in? L "AEIOU" -> drop 'name 1 + unless in? L "AEIOU" -> drop 'name [B F M]: ["b" "f" "m"] if L="B" -> B: "" From 449efce37ea3a7bc7475a2b69e4ca03429f860a7 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:57:32 +0200 Subject: [PATCH 14/24] updated RC example "Wagstaff primes" --- examples/rosetta/wagstaff primes.art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rosetta/wagstaff primes.art b/examples/rosetta/wagstaff primes.art index 0a235de4d4..3e33a70bba 100644 --- a/examples/rosetta/wagstaff primes.art +++ b/examples/rosetta/wagstaff primes.art @@ -7,7 +7,7 @@ wagstaff?: function [e][ summarize: function [n][ n: ~"|n|" s: size n - if s > 20 -> n: ((take n 10)++"...")++drop n s-10 + if s > 20 -> n: ((take n 10)++"...")++drop.times:s-10 n n ++ ~" (|s| digits)" ] From 425441df8e5576fbcc3aabec04b9439339ef0bf9 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 11:57:48 +0200 Subject: [PATCH 15/24] build update --- version/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/build b/version/build index dca5ef64f9..8745834501 100644 --- a/version/build +++ b/version/build @@ -1 +1 @@ -976 \ No newline at end of file +977 \ No newline at end of file From 1fc92a619de0bb1edd113d618123f7e1a3950724 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:07:48 +0200 Subject: [PATCH 16/24] Collections/drop: updated documentation example --- src/library/Collections.nim | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 7a50a3f80e..567bd8596d 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -381,16 +381,22 @@ proc defineSymbols*() = }, returns = {String, Block, Nothing}, example = """ + drop "xhello" ; => "hello" + .......... str: "some text" - drop str 5 ; => text - drop str neg 5 ; => some + drop.times:5 str ; => text + drop.times: neg 5 str ; => some .......... arr: @1..10 - drop 'arr 3 + drop.times:3 'arr arr ; => [4 5 6 7 8 9 10] .......... - drop [1 2 3] 3 ; => [] - drop [1 2 3] 4 ; => [] + drop [1 2 3] ; => [2 3] + .......... + drop.times:1 [1 2 3] ; => [2 3] + drop.times:2 [1 2 3] ; => [3] + drop.times:3 [1 2 3] ; => [] + drop.times:4 [1 2 3] ; => [] """: #======================================================= var times = 1 From 30b6ae41959fa1f62ad75ad705c4afe1d5c48610 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:08:41 +0200 Subject: [PATCH 17/24] minor edit --- src/library/Collections.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 567bd8596d..28a5620bd6 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -382,6 +382,7 @@ proc defineSymbols*() = returns = {String, Block, Nothing}, example = """ drop "xhello" ; => "hello" + drop drop "xhello" ; => "ello" .......... str: "some text" drop.times:5 str ; => text From 172929d215d1800d73cbbe7a7611073ff01e5076 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:12:47 +0200 Subject: [PATCH 18/24] Collections/chop: re-implemented as reverse `drop` (this way, negative `.times:` also work consistently) --- src/library/Collections.nim | 43 ++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 28a5620bd6..3043ff98c9 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -152,20 +152,39 @@ proc defineSymbols*() = if checkAttr("times"): times = aTimes.i - - if xKind == Literal: + + template numberInRange(container: untyped): untyped = + container.len >= abs(times) + + template drop(container: untyped): untyped = + if 0 < times: + container[times..^1] + else: + container[0.. container.high - abs(times)] + + if x.kind == Literal: ensureInPlace() - if InPlaced.kind == String: - InPlaced.s = InPlaced.s[0..^(times + 1)] - elif InPlaced.kind == Block: - if InPlaced.a.len > 0: - InPlaced.a = InPlaced.a[0..^(times + 1)] + case InPlaced.kind + of String: + if numberInRange(InPlaced.s): + InPlaced.s = InPlaced.s.drop() + else: + InPlaced.s = "" + of Block: + if numberInRange(InPlaced.a): + InPlaced.a = InPlaced.a.drop() + else: + InPlaced.a = newSeq[Value](0) + else: discard else: - if xKind == String: - push(newString(x.s[0..^(times + 1)])) - elif xKind == Block: - if x.a.len == 0: push(newBlock()) - else: push(newBlock(x.a[0..^(times + 1)])) + case x.kind + of String: + if numberInRange(x.s): push(newString(x.s.drop())) + else: push(newString("")) + of Block: + if numberInRange(x.a): push(newBlock(x.a.drop())) + else: push(newBlock()) + else: discard # TODO(Collections/combine) should also work with in-place Literals? From b0970f83dbf4594968b99a860b1891522ea59d00 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:12:57 +0200 Subject: [PATCH 19/24] build update --- version/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/build b/version/build index 8745834501..c9ebe1509d 100644 --- a/version/build +++ b/version/build @@ -1 +1 @@ -977 \ No newline at end of file +978 \ No newline at end of file From 1a090ceb7babb784fbbce21f22a0a6d4c8717eaa Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:19:18 +0200 Subject: [PATCH 20/24] important fix, albeit minor (= `.times:` in `chop` have to be negated first!) --- src/library/Collections.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 3043ff98c9..3428b33cb2 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -148,10 +148,10 @@ proc defineSymbols*() = chop.times: 3 "Arturo" ; Art """: #======================================================= - var times = 1 + var times = -1 if checkAttr("times"): - times = aTimes.i + times = -aTimes.i template numberInRange(container: untyped): untyped = container.len >= abs(times) From 9c88c2fa956ad602c9118d085defa8e81d243968 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:19:27 +0200 Subject: [PATCH 21/24] build update --- version/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/build b/version/build index c9ebe1509d..6fb439a5f6 100644 --- a/version/build +++ b/version/build @@ -1 +1 @@ -978 \ No newline at end of file +979 \ No newline at end of file From 3fe9b176a17b7a598c2bae37ac88dac506acece0 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:46:04 +0200 Subject: [PATCH 22/24] minor edit --- src/library/Collections.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 3428b33cb2..4d17e6cc0a 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -417,6 +417,9 @@ proc defineSymbols*() = drop.times:2 [1 2 3] ; => [3] drop.times:3 [1 2 3] ; => [] drop.times:4 [1 2 3] ; => [] + .......... + drop.times: neg 1 [1 2 3] ; => [1 2] + drop.times: neg 2 [1 2 3] ; => [1] """: #======================================================= var times = 1 From 9086aa16524ee1c247afd0b19c4d9a046541f1f5 Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:49:15 +0200 Subject: [PATCH 23/24] Collections/chop: updated documentation example --- src/library/Collections.nim | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/library/Collections.nim b/src/library/Collections.nim index 4d17e6cc0a..8dc87816a5 100644 --- a/src/library/Collections.nim +++ b/src/library/Collections.nim @@ -137,15 +137,26 @@ proc defineSymbols*() = }, returns = {String, Block, Nothing}, example = """ - print chop "books" ; book - print chop chop "books" ; boo + chop "hellox" ; => "hello" + chop chop "hellox" ; => "hell" .......... - str: "books" - chop 'str ; str: "book" + str: "some text" + chop.times:5 str ; => some + chop.times: neg 5 str ; => text + .......... + arr: @1..10 + chop.times:3 'arr + arr ; => [1 2 3 4 5 6 7] + .......... + chop [1 2 3] ; => [1 2] .......... - chop [1 2 3 4] ; => [1 2 3] + chop.times:1 [1 2 3] ; => [1 2] + chop.times:2 [1 2 3] ; => [1] + chop.times:3 [1 2 3] ; => [] + chop.times:4 [1 2 3] ; => [] .......... - chop.times: 3 "Arturo" ; Art + chop.times: neg 1 [1 2 3] ; => [2 3] + chop.times: neg 2 [1 2 3] ; => [3] """: #======================================================= var times = -1 From 29fcea7f84e71013a8dc0e9e01fc97473dd7d2cf Mon Sep 17 00:00:00 2001 From: drkameleon Date: Thu, 10 Aug 2023 12:49:23 +0200 Subject: [PATCH 24/24] build update --- version/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/build b/version/build index 6fb439a5f6..a637eba546 100644 --- a/version/build +++ b/version/build @@ -1 +1 @@ -979 \ No newline at end of file +980 \ No newline at end of file