cleaned up the remove procedure

cleanup
m455 2020-06-15 15:43:43 -04:00
parent 4c491e41c8
commit cbc8ae474a
1 changed files with 8 additions and 6 deletions

View File

@ -155,7 +155,8 @@
;; subtract 1 because the index starts at ;; subtract 1 because the index starts at
;; 0 under the hood, but the numbers presented from 'ls' ;; 0 under the hood, but the numbers presented from 'ls'
;; start at 1. ;; start at 1.
[item-number (sub1 (string->number string))] [item-number (string->number string)]
[item-number-sub1 (sub1 item-number)]
[list-length (length listof-nicethings)]) [list-length (length listof-nicethings)])
(if (and (not (null? listof-nicethings)) (if (and (not (null? listof-nicethings))
(number? item-number) (number? item-number)
@ -163,11 +164,12 @@
;; presented with a 0 option, so, if the user types ;; presented with a 0 option, so, if the user types
;; `nicethings rm 1` add back the 1 that was ;; `nicethings rm 1` add back the 1 that was
;; subtracted above ;; subtracted above
(positive? (add1 item-number)) (positive? item-number)
;; less than length, because the index ;; 1 less than length, because we want to
;; starts at 0 under the hood ;; remove the index number, which is one less
(< item-number list-length)) ;; than the item the user chose
(rm/remove-item listof-nicethings item-number) (< item-number-sub1 list-length))
(rm/remove-item listof-nicethings item-number-sub1)
(display-message-list 'item-not-found)))) (display-message-list 'item-not-found))))
;; ------------------------------------------------ ;; ------------------------------------------------