andreiformiga
2018-8-11 13:58:22

yeah you probably will be better served by using a GUI library


andreiformiga
2018-8-11 13:59:54

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


slack1
2018-8-11 20:20:05

Is there a built-in function that checks whether a type is valid for the for iterators?


slack1
2018-8-11 20:20:33

Such as foldable?


soegaard2
2018-8-11 20:20:42

Maybe sequence?


slack1
2018-8-11 20:20:56

I tried to use sequence? but it considers numbers a sequence


slack1
2018-8-11 20:21:07

I guess I should just write a custom checker


slack1
2018-8-11 20:21:18

(that causes my numeric function go to into a loop)


soegaard2
2018-8-11 20:21:18

(for ([x 3]) …) works fine.


slack1
2018-8-11 20:24:40
(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)))))

slack1
2018-8-11 20:24:45

I was trying to do something like this


soegaard2
2018-8-11 20:30:49

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))


slack1
2018-8-11 20:41:32

Ah sorry for not being clear; my issue was that (digits->natural 123) would produce an entirely large and different number


slack1
2018-8-11 20:41:53

And sequence? wasn’t enough to guard against that, because I guess numbers are a sequential type


soegaard2
2018-8-11 20:42:33

Okay, so want all digits to be between 0 and base ?


slack1
2018-8-11 20:42:59

yes


soegaard2
2018-8-11 20:44:03

`(unless (andmap (lambda (x) (<= 0 x (- base 1))) nats) (error ’digits->natrul “yada yada”)