Re: [racket-users] HTDP2e Exercise 309

2020-03-05 Thread Aron Zvi
Thanks. I initially tried as below with first pattern [empty empty] and 
empty apparently is a variable that will match a non-empty list. I need to 
use  '*()* 

(define (words-on-line llos)
  (match llos
  [*empty* empty]
  [(list a b ...) ))

On Friday, 6 March 2020 04:01:46 UTC+7, Daniel Prager wrote:
>
> Hint:
>
> (define (words-on-line llos)
>   (match llos
>   ['() empty]
>   [(list a b ...) ))
>
> Dan
>

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/d8b94ae8-50de-4b66-ac16-7d3225f56b8b%40googlegroups.com.


[racket-users] FFI, provide cstruct-out?

2020-03-05 Thread Peter Samarin
Hi all,

Is there a way to provide all bindings generated by define-cstruct?

Like (provide (struct-out foo)) but for C structs?

Thanks!
Peter

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/5b7f1a0f-abd3-41b0-9eb5-30ecc3e11bf1%40googlegroups.com.


Re: [racket-users] HTDP2e Exercise 309

2020-03-05 Thread Daniel Prager
Hint:

(define (words-on-line llos)
  (match llos
  ['() empty]
  [(list a b ...) ))

Dan

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFKxZVW-wbhphJrbeJSJQ39pQG9jKmyFUOh75A3Rb-4oauZUSA%40mail.gmail.com.


Re: [racket-users] "invalid memory reference" issue

2020-03-05 Thread Matthew Flatt
I've pushed a repair for the development version of Racket CS. The
problem was related to computing a hash code of an object (i.e., an
instance of a class).

If you need a workaround to keep using the released version of Racket
CS, it may involve supplying explicit equality and hash-code functions
for your `Equal%` class.

Thanks for the report!

At Thu, 5 Mar 2020 04:07:48 -0800 (PST), hashim muqtadir wrote:
> Hello,
> 
> I have some code that uses my library, "remap". It previously used to work, 
> but in Racket CS 7.6, it fails saying "invalid memory reference.  Some 
> debugging context lost".
> Clicking the crosses in DrRacket gives this backtrace:
> 
> invalid memory reference.  Some debugging context lost
> 
> /home/hashim/racket/collects/racket/private/for.rkt: 2020:10 
> (hash-set table key val
> 
> /home/hashim/racket/collects/racket/private/for.rkt: 1503:16 
>   (let-values ([(fold-var ...) (let () expr1 expr ...)])
>   (values fold-var ...)]
> 
> /home/hashim/racket/collects/racket/private/for.rkt: 1543:38 
>   #'(let-values ([(fold-var ...)
> (for/foldX/derived 
> [orig-stx inner-recur nested? #f ()]
>   ([fold-var fold-var] 
> ...)
>   next-k break-k 
> final?-id
>   rest expr1 . body)])
> (if (and post-guard ... (not 
> final?-id))
> (for-loop fold-var ... loop-arg 
> ... ...)
> next-k)))
> 
> My tests, that use the library functions, seem to work, but for some reason 
> when I'm building a hash from my structures.
> The file found 
> https://gitlab.com/hashimmm/remap/-/blob/96f1db518c4d9bb8f2da44ae403ab50332212c
> 9c/issue.rkt 
> is present in the "issue" branch in my repo and running this file in 
> DrRacket will reproduce the problem.
> 
> From the file, removing the measurement-units table definition and its 
> references fixes the problem (the memory error then no longer occurs).
> 
> Any ideas what's up with this? I'd be happy to provide more information to 
> narrow this down, but I'm not really sure how.
> 
> -- 
> 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 racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/afec7b07-7f96-4d7f-ac59-8eb54446
> 2709%40googlegroups.com.

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/5e614817.1c69fb81.73043.5ebdSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


[racket-users] HTDP2e Exercise 309

2020-03-05 Thread Aron Zvi
Hey Guys,

I do not see how to apply pattern matching to this problem. 
Using for/list as below makes the most sense to me and I do not see how to 
fit in pattern matching

; [List-of [List-of String]] -> [List-of Natural]
; produces list of number of Strings per item in a llos
(check-expect (words-on-line empty) empty)
(check-expect (words-on-line (list empty)) (list 0))
(check-expect (words-on-line (list (list "22" "rr" "ff") (list "22" "rr"))) 
(list 3 2))

(define (words-on-line llos)
  (for/list ((los llos))
(length los)))

Can I get a hint?

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/28814482-5ad2-4b8f-9e40-c0b83ffcb30c%40googlegroups.com.


[racket-users] "invalid memory reference" issue

2020-03-05 Thread hashim muqtadir
Hello,

I have some code that uses my library, "remap". It previously used to work, 
but in Racket CS 7.6, it fails saying "invalid memory reference.  Some 
debugging context lost".
Clicking the crosses in DrRacket gives this backtrace:

invalid memory reference.  Some debugging context lost

/home/hashim/racket/collects/racket/private/for.rkt: 2020:10 
(hash-set table key val

/home/hashim/racket/collects/racket/private/for.rkt: 1503:16 
  (let-values ([(fold-var ...) (let () expr1 expr ...)])
  (values fold-var ...)]

/home/hashim/racket/collects/racket/private/for.rkt: 1543:38 
  #'(let-values ([(fold-var ...)
(for/foldX/derived 
[orig-stx inner-recur nested? #f ()]
  ([fold-var fold-var] 
...)
  next-k break-k 
final?-id
  rest expr1 . body)])
(if (and post-guard ... (not 
final?-id))
(for-loop fold-var ... loop-arg 
... ...)
next-k)))

My tests, that use the library functions, seem to work, but for some reason 
when I'm building a hash from my structures.
The file found 
https://gitlab.com/hashimmm/remap/-/blob/96f1db518c4d9bb8f2da44ae403ab50332212c9c/issue.rkt
 
is present in the "issue" branch in my repo and running this file in 
DrRacket will reproduce the problem.

>From the file, removing the measurement-units table definition and its 
references fixes the problem (the memory error then no longer occurs).

Any ideas what's up with this? I'd be happy to provide more information to 
narrow this down, but I'm not really sure how.

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/afec7b07-7f96-4d7f-ac59-8eb544462709%40googlegroups.com.


Re: [racket-users] re-run really fast!

2020-03-05 Thread Robby Findler
Some time ago (a lot more than a week), DrRacket started using the result
of online expansion to run (look for the spiky green ball to know when it
will work). It doesn't work in error trace mode tho.

Could that be it?

Robby

On Thu, Mar 5, 2020 at 12:25 AM 'John Clements' via users-redirect <
us...@plt-scheme.org> wrote:

> Okay, I’m probably under a rock and just haven’t read my e-mail in a week,
> but … I just noticed that re-running a long TR file of 900 lines took ONE
> second, rather than eleven. It appears to me that either TR or DrRacket or
> both are now cooperating to not re-compile when no edits have been made. Is
> that a recent change, or am I just easily pleased?
>
> John
>
> --
> 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 racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/0dd2ace8-3633-42d3-8e4d-943bf5f62791%40mtasv.net
> .
>

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAL3TdOOwv7DeiySjai13nTYK6GCP-N5V7o_6eqGRdz2ZZxGc4A%40mail.gmail.com.


[racket-users] Issue with define-type and typed classes

2020-03-05 Thread hashim muqtadir
So I have this file, found here: 
https://gitlab.com/hashimmm/remap/-/blob/3682db9fff3bc5007833e07bf9a9ed6e8e0170a9/private/tables.rkt

Lines 51 through 55 say:

(define-type (Func<%> A)  (BaseFunc<%> A FuncAnyParam))(define-type BoolFunc<%> 
(Func<%> BooleanColumn))(define-type AnyFunc<%> (Func<%> ColIdent))

And this used to work on older versions of racket, say Racket BC 7.4

But on Racket CS 7.6, I get an error on this line: 
(define-type AnyFunc<%> (Func<%> ColIdent))

Even though (a) it doesn't throw an error on the line before it, and
(b) replacing it with (define-type AnyFunc<%> (BaseFunc<%> ColIdent 
FuncAnyParam))
works.

I thought the way define-type works is that 
(Func<%> ColIdent)
would expand into (BaseFunc<%> ColIdent FuncAnyParam)

I've had similar problems with define-type previously where I'd think it would 
just expand
by substituting the parameter but it doesn't seem to really do that. I don't 
have any
trivial example to show, though. Fiddling around eventually gets it to work.

I'd really appreciate some help as to how to think about what define-type does 
in my head.

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8d04a193-58b2-4b49-8e23-642f115f401b%40googlegroups.com.