From 8d9506d2fe2063d9b5d4604e5d3d7c2b2ce3df56 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 7 Jul 2021 12:38:38 -0400 Subject: =?UTF-8?q?Mention=20=C2=AF1=E2=8A=91=20as=20the=20obvious=20way?= =?UTF-8?q?=20to=20get=20the=20last=20element?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/pick.md | 3 ++- docs/doc/pick.html | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/pick.md b/doc/pick.md index 12a7003c..425b8cf9 100644 --- a/doc/pick.md +++ b/doc/pick.md @@ -52,9 +52,10 @@ If `𝕩` is empty then Pick always results in an error. First never gives an er So one way to find the fill element for an array `𝕩` of any shape is `⊑0⥊𝕩`. -In APL it's common to get the last element of a list with an idiom that translates to `⊑⌽`, or First-[Reverse](reverse.md). I prefer to use [Fold](fold.md) with the Right [identity function](identity.md). +In APL it's common to get the last element of a list with an idiom that translates to `⊑⌽`, or First-[Reverse](reverse.md). In BQN the most straightforward way is to select with index `¯1` instead. I also sometimes use [Fold](fold.md) with the Right [identity function](identity.md). ⊑⌽ "last" + ¯1⊑ "last" ⊢´ "last" ## Many elements diff --git a/docs/doc/pick.html b/docs/doc/pick.html index 3f5495aa..0926b3a0 100644 --- a/docs/doc/pick.html +++ b/docs/doc/pick.html @@ -64,8 +64,10 @@ ⟨ " " ⟨ 0 0 0 0 ⟩ ⟩

So one way to find the fill element for an array 𝕩 of any shape is 0𝕩.

-

In APL it's common to get the last element of a list with an idiom that translates to ⊑⌽, or First-Reverse. I prefer to use Fold with the Right identity function.

-↗️
    ⊑⌽ "last"
+

In APL it's common to get the last element of a list with an idiom that translates to ⊑⌽, or First-Reverse. In BQN the most straightforward way is to select with index ¯1 instead. I also sometimes use Fold with the Right identity function.

+↗️
    ⊑⌽ "last"
+'t'
+    ¯1 "last"
 't'
     ´ "last"
 't'
-- 
cgit v1.2.3