hi, I'm trying to do something slightly harder than what the attached
example tries to do, but this example suffices to show that I, evidently,
am missing something about how for/fold and/or #:break work together.
(I have used both before, but have gotten out of practice with racket of
late and am stuck longer on this than seems reasonable.)
I expect both tests to pass, but both fail (the "j" for jewel in "xxjxx")
is seen but not "found", as it were.
I'd be grateful for a bug fix and/or explanation.
Cheers,
Tim Hanson
--------
#lang racket
(require rackunit)
(define (port->char-stream aport)
(printf "(port->char-stream aport)~n")
(define (process-next-ch-iter)
(let ([ch (read-char aport)])
(printf "p->cs ch: ~a~n" ch)
(if (eof-object? ch)
empty-stream
(stream-cons
ch
(process-next-ch-iter)))))
(process-next-ch-iter))
(let ([my-port
(open-input-string "xxjxx")])
(let ([ch-stream (port->char-stream my-port)])
(let-values ([(pos-found? pos)
(for/fold ([j-found? #f]
[pos 0])
(#:break j-found?
;#:final j-found?
[ch ch-stream]
[ch-idx (in-naturals 1)])
(begin
(printf "ch: ~a~n" ch)
(printf "ch-idx: ~a~n" ch-idx)
(printf "(eq? ch #\\j): ~a~n" (eq? ch #\j))
(values
(eq? ch #\j)
ch-idx)))])
(check-equal? pos-found? #t)
(check-equal? pos 3)
(close-input-port my-port))))
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/beaa2ef6-afd2-4686-829a-390eb69f5620n%40googlegroups.com.
Beyond the Racket Users Google Group, Racket Discussions take place on
Discourse ( https://racket.discourse.group/ ) and Discord (
https://discord.gg/6Zq8sH5 ). Discussion (but less active) also takes place on
the Racket Slack https://racket.slack.com/ ( sign up at
https://racket-slack.herokuapp.com/ ), and IRC #racket
https://kiwiirc.com/nextclient/irc.libera.chat/#racket
---
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/b2f243a7-9ae9-40c5-97fb-3d159bdbbdf8n%40googlegroups.com.