made the number-prefixing a little easier to read code-wise
parent
9adb25c4a2
commit
67a1ebb988
19
util.rkt
19
util.rkt
|
@ -38,9 +38,9 @@
|
|||
(list:empty? (file->string-list lst)))
|
||||
|
||||
(define (get-removed-item lst args)
|
||||
;; Subtract one from what the user chose, because they are
|
||||
;; are actually viewing the list numbers as human numbers,
|
||||
;; so what they see is actual-number +1
|
||||
;; Subtract one from what the user chose, because what they are actually
|
||||
;; viewing is a list starting from "1" rather than "0". Under the hood,
|
||||
;; the real list starts at 0.
|
||||
(list-ref (file->string-list lst) (sub1 (string->number args))))
|
||||
|
||||
(define (surround-item-in-quotation-marks args)
|
||||
|
@ -50,21 +50,22 @@
|
|||
(string-append lst ". "))
|
||||
|
||||
(define (prefix-item-with-number lst)
|
||||
;; Take the list made in the first (map), which is
|
||||
;; '(1 2 3 ...), and append that to each item in a list
|
||||
(map string-append
|
||||
;; Note: compose starts from the last element in it's
|
||||
;; list, so that would be add1 here
|
||||
(map (compose prefix-item-with-period number->string add1)
|
||||
(list:range (length lst)))
|
||||
;; list. In this case, it starts at (number->string).
|
||||
(map (compose1 prefix-item-with-period number->string)
|
||||
(list:range 1 (add1 (length lst))))
|
||||
lst))
|
||||
|
||||
(define (display-prettified-program-file)
|
||||
(display
|
||||
(string:string-join
|
||||
(display (string:string-join
|
||||
(prefix-item-with-number (file->string-list config:path-to-file))
|
||||
"\n"
|
||||
#:after-last "\n")))
|
||||
|
||||
;; This one is pretty wild
|
||||
;; Don't ask
|
||||
(define (append-item-to-end args lst)
|
||||
(reverse (cons args (reverse (file->string-list lst)))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue