For the record, this worked:
#lang typed/racket
(require typed/racket/class)
(define aninteger%
(class object%
(super-new)
(init-field [x : Integer 0])
(: getxinternal Integer)
(define getxinternal x)
(: getx (-> Integer))
(define/public (getx) getxinternal)))
(print
When i try typed/racket :
#lang typed/racket
(define (integerclass x)
(define (getx) x)
(define (setx! [x_new : Integer]) (set! x x_new))
(define (add [y : integerclass]) : integerclass (integerclass (+ 1 (y
'getx
(lambda (message . args)
(case message
((getx) (apply g
1. If the intention is to create a class, then I'd use the class form.
https://docs.racket-lang.org/reference/createclass.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._class%2A%29%29
Not that there's anything overtly wrong with using a closure, but common
validation tasks r
Following code makes an "integerclass" with an "add" method :
#lang racket
(define (integerclass x)
(define (getx) x)
(define (setx! x_new) (set! x x_new))
(define (add y)(integerclass (+ x (y 'getx
(lambda (message . args)
(case message
((getx) (apply getxargs))
Yes, I’ll add this. It slightly increases the pain density, especially since I
think students likely to mistakenly write
(list (? symbol? #{s : Symbol}) …)
instead of the correct
(list (? symbol? #{s : (Listof Symbol)}) …)
… but it’s probably better than having to cast.
Thanks!
John
> On F
On Sat, Feb 15, 2020 at 1:23 PM 'John Clements' via users-redirect <
us...@plt-scheme.org> wrote:
> Yes, absolutely. One reason that students in my class wind up using cast
> quite frequently in their parsers is that they use patterns like (list (?
> symbol s) …) which (as I recall) expand into un
Wait, we *all* have postmark libraries?
Sigh.
John
> On Jan 23, 2020, at 16:29, Jens Axel Søgaard wrote:
>
> Den tor. 23. jan. 2020 kl. 01.47 skrev Matthew Butterick :
> I concur on Postmark. For 2+ yrs I've used it with the Racket web server for
> mbtype.com. I pass the server settings to `
Belatedly: awesome, many thanks!
John
> On Jan 27, 2020, at 02:39, Sean Kemplay wrote:
>
>
> This is a good (free) course that takes you the lates best practices of JS
> (getting more functional), react and then react native.
>
> https://www.edx.org/course/cs50s-mobile-app-development-with-r
Have you taken a look at How To Design Programs? At the end of section one, you
should have what you need to build these games and others like them:
https://htdp.org/2019-02-24/part_one.html
John Clements
> On Feb 3, 2020, at 03:31, Wilzoo wrote:
>
> Hi guys, so I am working on rolling dice g
Did anyone suggest this code to you? Apologies if I’m re-treading an old
conversation.
#lang typed/racket
(: string2value (-> String Integer))
(define (string2value str)
(define maybe-integer (string->number str))
(cond [(exact-integer? maybe-integer) maybe-integer]
[else (error 'stri
??
> (string2value "-1234")
- : Integer
-28766
> (string2value "abcd")
- : Integer
54562
>
Is this your desired behavior?
> On Feb 12, 2020, at 16:43, Alain De Vos wrote:
>
> I came to the following result as conversion function :
>
> #lang typed/racket
> (: string2value (-> String Integer))
Yes, absolutely. One reason that students in my class wind up using cast quite
frequently in their parsers is that they use patterns like (list (? symbol s)
…) which (as I recall) expand into unannotated lambda’s, and always require a
cast. I write that up here:
https://www.brinckerhoff.org/cle
Den lør. 15. feb. 2020 kl. 13.44 skrev greadey :
> I have written a programme to compute a bootstrapped mean etc. I
> successfully wrote it using lists both untyped and in typed/racket.
> I am interested in optimising the code and having seen that typed racket
> performs faster (for lists) I am i
Hi there,
I have written a programme to compute a bootstrapped mean etc. I
successfully wrote it using lists both untyped and in typed/racket.
I am interested in optimising the code and having seen that typed racket
performs faster (for lists) I am interested in seeing if I get a
performance i
14 matches
Mail list logo