我在尝试此代码时遇到错误:
(define odc (odbc-connect #:dsn DSNNAME #:user USER #:password PASSWORD));
(define-struct attendance-event (date flag)#:transparent)
(define-struct list-attendance-events (v)
#:methods gen:stream
[(define (stream-empty? stream)
(empty? (list-attendance-events-v stream)))
(define (stream-first stream)
(first (list-attendance-events-v stream)))
(define (stream-rest stream)
(rest (list-attendance-events-v stream)))])
(define list-of-events (
(for/list ([(date code)
(in-query odc "select date, code from attendance
where student_id = ? and term_code = ?
"12345" "654321")]))
(make-attendance-event date code)
我有for / list工作,但我改变了一些东西并打破了它。我可以得到'第一个'元素,我假设'最后',并检查空?
发生了什么事?
答案 0 :(得分:2)
也许这个?
(define list-of-events
(for/list ([(date code)
(in-query odc "select date, code from attendance
where student_id = ? and term_code = ?"
"12345" "654321")])
(make-attendance-event date code)))