1
0
Disbranĉigi 0

Remove alist-car-ref, use cons in alists

This commit is contained in:
Jaidyn Ann 2023-01-08 18:25:59 -06:00
parent 74e42fbf4d
commit ffa32241f7

View File

@ -58,14 +58,6 @@
;; Misc. helpers ;; Misc. helpers
;; ————————————————————————————————————————————————————————————————————————————— ;; —————————————————————————————————————————————————————————————————————————————
;; Just car's the value of alist-ref (if it exists)
(define (alist-car-ref key alist)
(let ([value (alist-ref key alist)])
(if value
(car value)
#f)))
;; By Göran Weinholt, from the Scheme Cookbook ;; By Göran Weinholt, from the Scheme Cookbook
;; https://cookbook.scheme.org/format-unix-timestamp/ ;; https://cookbook.scheme.org/format-unix-timestamp/
(define (time-unix->time-utc seconds) (define (time-unix->time-utc seconds)
@ -125,9 +117,9 @@
;; received messages, but ircc has to sneakily process some responses itself, ;; received messages, but ircc has to sneakily process some responses itself,
;; to ensure basic functionality (i.e., pings, chanlist, userlist, etc.) ;; to ensure basic functionality (i.e., pings, chanlist, userlist, etc.)
(define (irc:process-alist-internally conn alist) (define (irc:process-alist-internally conn alist)
(let ([command (alist-car-ref 'command alist)] (let ([command (alist-ref 'command alist)]
[reply (alist-car-ref 'reply alist)] [reply (alist-ref 'reply alist)]
[sender (alist-car-ref 'sender alist)] [sender (alist-ref 'sender alist)]
[params (alist-ref 'params alist)]) [params (alist-ref 'params alist)])
(if command (if command
(irc:process-command-internally conn command params sender) (irc:process-command-internally conn command params sender)
@ -225,7 +217,7 @@
;; Return a pice of stored data relating to a user, by nick ;; Return a pice of stored data relating to a user, by nick
(define (irc:user-get conn nick key) (define (irc:user-get conn nick key)
(irc:user-add! conn nick) (irc:user-add! conn nick)
(alist-car-ref key (irc:user-alist conn nick))) (alist-ref key (irc:user-alist conn nick)))
;; Return an alist of data stored relating to the given user ;; Return an alist of data stored relating to the given user
@ -320,10 +312,10 @@
[command (car verb)] [command (car verb)]
[reply (string->number (car verb))] [reply (string->number (car verb))]
[params (irc:line-verb-params verb)]) [params (irc:line-verb-params verb)])
`((command ,(if (not reply) command #f)) `((command . ,(if (not reply) command #f))
(reply ,reply) (reply . ,reply)
,(append '(params) params) ,(append '(params) params)
(sender ,sender) (sender . ,sender)
,(append '(tags) tags)))) ,(append '(tags) tags))))
@ -474,10 +466,10 @@
[reply (alist-ref 'reply output)] [reply (alist-ref 'reply output)]
[params (alist-ref 'params output)] [params (alist-ref 'params output)]
[sender (alist-ref 'sender output)]) [sender (alist-ref 'sender output)])
(if (and on-command (car command)) (if (and on-command command)
(apply on-command (append (list connection) command (list params) sender))) (apply on-command (list connection command params sender)))
(if (and on-reply (car reply)) (if (and on-reply reply)
(apply on-reply (append (list connection) reply (list params) sender))) (apply on-reply (list connection reply params sender)))
(irc:loop connection on-command on-reply))) (irc:loop connection on-command on-reply)))