yeah you probably will be better served by using a GUI library
I have simple SDL bindings that are working for my purposes right now (based on racket-sdl which did not exactly work for me), but it’s not published as a package because it’s not polished
Is there a built-in function that checks whether a type is valid for the for iterators?
Such as foldable?
Maybe sequence?
I tried to use sequence?
but it considers numbers a sequence
I guess I should just write a custom checker
(that causes my numeric function go to into a loop)
(for ([x 3]) …) works fine.
(fn (digits->natural nats #:base [base 10])
(cond [(not-serial? nats) (error "not sequential type.")])
(for/fold ([place 1] [sum 0] #:result sum)
([n nats])
(values (* place base) (+ sum (* n place)))))
I was trying to do something like this
It seems to work fine? (define (digits->natural nats #:base [base 10])
(for/fold ([place 1] [sum 0] #:result sum)
([n (reverse nats)])
(values (* place base) (+ sum (* n place)))))
(digits->natural '(1 2 3))
Ah sorry for not being clear; my issue was that (digits->natural 123)
would produce an entirely large and different number
And sequence?
wasn’t enough to guard against that, because I guess numbers are a sequential type
Okay, so want all digits to be between 0 and base ?
yes
`(unless (andmap (lambda (x) (<= 0 x (- base 1))) nats) (error ’digits->natrul “yada yada”)