From d810724cb710244113624bbb9360344f678a7df5 Mon Sep 17 00:00:00 2001 From: m455 Date: Mon, 15 Jun 2020 16:32:02 -0400 Subject: [PATCH] added a comment --- src/nicethings.rkt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/nicethings.rkt b/src/nicethings.rkt index bb4e151..7dc9375 100644 --- a/src/nicethings.rkt +++ b/src/nicethings.rkt @@ -160,14 +160,23 @@ [list-length (length listof-nicethings)]) (if (and (not (null? listof-nicethings)) (number? item-number) - ;; zero is okay in an index, but the user is never - ;; presented with a 0 option, so, if the user types - ;; `nicethings rm 1` add back the 1 that was - ;; subtracted above (positive? item-number) ;; 1 less than length, because we want to ;; remove the index number, which is one less ;; than the item the user chose + ;; Example: + ;; We have a list length of 3: + ;; '(1 2 3) + ;; `list-ref` in rm/remove-item above + ;; uses an index that starts at 0, so + ;; the index of the numbers above are: + ;; '(0 1 2) + ;; The 2 is the last index number in a + ;; list of length 3, which is what we + ;; want, because if you try to remove + ;; an index larger than 2, such as the + ;; list length 3, then that would be + ;; an error (< item-number-sub1 list-length)) (rm/remove-item listof-nicethings item-number-sub1) (display-message-list 'item-not-found))))