Re: [racket-users] Pattern Matching

2020-10-06 Thread George Neuner


On 10/6/2020 10:41 AM, Beatriz Moreira wrote:

Hello,

Yes, my idea is to check the type of the parameters. I still have to 
add the types to my code, but I was trying to see if I could do it 
without them (just pattern matching), as the functions of type *f* are 
in the declaration of the contract.


Can you access this link? 
https://bitbucket.org/beatrizmoreira/msc/src/master/fwsollast.rkt 



Thank you for your answer :D


I thought you were working with match in Racket ... Redex is its own 
language, and I haven't done anything with it.


Sorry, I can't help.
George


--
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/caef9073-1d94-6799-cfc6-730058cc1c7d%40comcast.net.


Re: [racket-users] Differences running HtDP programs from DrRacket IDE vs racket command line

2020-10-06 Thread Robby Findler
Great! No guarantee, but probably this is the right repo:
https://github.com/racket/htdp/issues

Robby


On Tue, Oct 6, 2020 at 9:04 AM Nick Lee  wrote:

> Thanks again Robby! I will create issues on the drracket github issues
> page.
>
> On Tuesday, October 6, 2020 at 9:23:49 AM UTC-4 Robby Findler wrote:
>
>> On Tue, Oct 6, 2020 at 1:50 AM Nick Lee  wrote:
>>
>>> Thank you very much Robby for the quick reply! I should have mentioned
>>> that our students are using Beginning Student by setting the Language to
>>> that, rather than adding #lang htdp/bsl.
>>>
>>
>> Right, I got that. I merely meant to say that those are likely to be the
>> same bug.
>>
>>
>>> It appears this makes a difference. So the whole file looks like:
>>>
>>> ;; The first three lines of this file were inserted by DrRacket. They
>>> record metadata
>>> ;; about the language level of this file in a form that our tools can
>>> easily process.
>>> #reader(lib "htdp-beginner-reader.ss" "lang")((modname file)
>>> (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor
>>> repeating-decimal #f #t none #f () #f)))
>>> (define (quasiquote x) x)
>>> (define (f x) 123)
>>> `(f 888)
>>>
>>> Running this file in command line with "racket file.rkt" doesn't show
>>> any errors for me. I'm using DrRacket 7.8 if it matters.
>>>
>>>
>> Ah, oops. I had mistakenly tested with BSL+. I see this error too, now.
>>
>> Robby
>>
>> --
> 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/f86ec3c9-e0c3-4616-b242-cc419ef33059n%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/CAL3TdONTR%2Bd-8RsVHWbRaMZ%3DLjDktVsuriOuxXd1CA12soKTUg%40mail.gmail.com.


Re: [racket-users] Pattern Matching

2020-10-06 Thread Beatriz Moreira
Hello,

Yes, my idea is to check the type of the parameters. I still have to add 
the types to my code, but I was trying to see if I could do it without them 
(just pattern matching), as the functions of type *f* are in the 
declaration of the contract.

Can you access this link? 
https://bitbucket.org/beatrizmoreira/msc/src/master/fwsollast.rkt

Thank you for your answer :D
A terça-feira, 29 de setembro de 2020 à(s) 17:20:58 UTC+1, 
wesley@gmail.com escreveu:

> Hello Beatriz,
>
> Is this something like contracts with parameters? That sounds neat, 
> actually.
>
> Anyway, this seems more like syntax analysis rather than string matching, 
> but I'm not entirely certain as to what your approach is. I can't access 
> the file you linked.
>
> If this _is_ syntax analysis, then maybe a macro using `syntax-case` or 
> `syntax-parse` would serve you better? Again, I'm not exactly sure what 
> your approach is, and I'm sorry for that.
> On Monday, September 28, 2020 at 3:31:11 PM UTC-4 gneuner2 wrote:
>
>>
>> On 9/28/2020 10:50 AM, Beatriz Moreira wrote:
>>
>> Hello, 
>> I would like to know how do I match multiple variables to a regular 
>> expression.
>> My idea is to match every *f* variables (f...) to an *f* in ((contract C 
>> ((T x) ...) ((T f)) ...) ... ).
>> I am trying to implement a core language for smart contracts in Racket, 
>> but I need to have as pre condition in my reduction rules that the *f* is 
>> a function in one of the contracts.
>> Thank you! :) 
>>
>>
>> 'regexp-match*' outputs a list of matched strings, and match has an apply 
>> clause: '(app *expr* pats ...)' which evaluates *expr* and tries to 
>> match the output.  My first thought would be to try something like:
>>
>>   match ( inp )
>> :
>> ((app (regexp-match* pattern inp) match1 match2 ... )
>>... )
>> :
>>
>> Caveat ... I've never tried to do this.  If match doesn't like this 
>> approach (or something close to it), then I would separately perform the 
>> regexp-match* and the pattern match on its output list.
>>
>> Hope this helps,
>> George
>>
>> https://docs.racket-lang.org/reference/regexp.html
>> https://docs.racket-lang.org/reference/match.html
>>
>

-- 
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/76283498-990f-4c7c-b445-0d40f10108can%40googlegroups.com.


Re: [racket-users] Pattern Matching

2020-10-06 Thread Beatriz Moreira
Hello,
I don't think this is what im looking for, but thank you very much :D 

A segunda-feira, 28 de setembro de 2020 à(s) 20:31:11 UTC+1, gneuner2 
escreveu:

>
> On 9/28/2020 10:50 AM, Beatriz Moreira wrote:
>
> Hello, 
> I would like to know how do I match multiple variables to a regular 
> expression.
> My idea is to match every *f* variables (f...) to an *f* in ((contract C 
> ((T x) ...) ((T f)) ...) ... ).
> I am trying to implement a core language for smart contracts in Racket, 
> but I need to have as pre condition in my reduction rules that the *f* is 
> a function in one of the contracts.
> Thank you! :) 
>
>
> 'regexp-match*' outputs a list of matched strings, and match has an apply 
> clause: '(app *expr* pats ...)' which evaluates *expr* and tries to match 
> the output.  My first thought would be to try something like:
>
>   match ( inp )
> :
> ((app (regexp-match* pattern inp) match1 match2 ... )
>... )
> :
>
> Caveat ... I've never tried to do this.  If match doesn't like this 
> approach (or something close to it), then I would separately perform the 
> regexp-match* and the pattern match on its output list.
>
> Hope this helps,
> George
>
> https://docs.racket-lang.org/reference/regexp.html
> https://docs.racket-lang.org/reference/match.html
>

-- 
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/3d0e5945-a81e-4424-99c5-96f6d0b7b198n%40googlegroups.com.


Re: [racket-users] Differences running HtDP programs from DrRacket IDE vs racket command line

2020-10-06 Thread Nick Lee
Thanks again Robby! I will create issues on the drracket github issues page.

On Tuesday, October 6, 2020 at 9:23:49 AM UTC-4 Robby Findler wrote:

> On Tue, Oct 6, 2020 at 1:50 AM Nick Lee  wrote:
>
>> Thank you very much Robby for the quick reply! I should have mentioned 
>> that our students are using Beginning Student by setting the Language to 
>> that, rather than adding #lang htdp/bsl. 
>>
>
> Right, I got that. I merely meant to say that those are likely to be the 
> same bug.
>  
>
>> It appears this makes a difference. So the whole file looks like:
>>
>> ;; The first three lines of this file were inserted by DrRacket. They 
>> record metadata
>> ;; about the language level of this file in a form that our tools can 
>> easily process.
>> #reader(lib "htdp-beginner-reader.ss" "lang")((modname file) 
>> (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor 
>> repeating-decimal #f #t none #f () #f)))
>> (define (quasiquote x) x)
>> (define (f x) 123)
>> `(f 888)
>>
>> Running this file in command line with "racket file.rkt" doesn't show any 
>> errors for me. I'm using DrRacket 7.8 if it matters.
>>
>>
> Ah, oops. I had mistakenly tested with BSL+. I see this error too, now.
>
> Robby
>
>

-- 
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/f86ec3c9-e0c3-4616-b242-cc419ef33059n%40googlegroups.com.


Re: [racket-users] Differences running HtDP programs from DrRacket IDE vs racket command line

2020-10-06 Thread Robby Findler
On Tue, Oct 6, 2020 at 1:50 AM Nick Lee  wrote:

> Thank you very much Robby for the quick reply! I should have mentioned
> that our students are using Beginning Student by setting the Language to
> that, rather than adding #lang htdp/bsl.
>

Right, I got that. I merely meant to say that those are likely to be the
same bug.


> It appears this makes a difference. So the whole file looks like:
>
> ;; The first three lines of this file were inserted by DrRacket. They
> record metadata
> ;; about the language level of this file in a form that our tools can
> easily process.
> #reader(lib "htdp-beginner-reader.ss" "lang")((modname file)
> (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor
> repeating-decimal #f #t none #f () #f)))
> (define (quasiquote x) x)
> (define (f x) 123)
> `(f 888)
>
> Running this file in command line with "racket file.rkt" doesn't show any
> errors for me. I'm using DrRacket 7.8 if it matters.
>
>
Ah, oops. I had mistakenly tested with BSL+. I see this error too, now.

Robby

-- 
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/CAL3TdOOYXWE_FMyzcEdwEG%3DpcRjAEzSuq%2B7X%2BMCwoUSmEcDxEA%40mail.gmail.com.


[racket-users] Re: access a `#` from c code

2020-10-06 Thread Nate Griswold
I realized i already asked this question and Matthew Flatt had responded
like this, for anyone wondering:

---

I see that there's not a good way right now, but here's a workaround
that uses information about the current layout:

A cpointer value is implemented as a Chez Scheme record with either 1
field or 2 fields. There are 2 fields only when the cpointer has an
offset as a result of `ptr-add`, so you can probably ignore that.

To extract the first field, assume that a record has the same layout as
a vector, so use `Svector_ref(p, 0)` to extra the field from the
cpointer `p`.

Then you can use `Sunsigned_value()` to convert that field value to a
pointer-sized integer, then case.

I might have some part of that wrong, but it should be close... Of
course, there should be better support for record-field access and
cpointer extraction, so I'll add to the API.

---

Nate


On Mon, Oct 5, 2020 at 3:59 AM Nate Griswold  wrote:

> I have a temporary workaround where i have created an ffi function
> racket-side to call into c, so that i can automatically use the _cptr's
> racket-to-c function. I wonder if there is a way to manually extract the c
> value for the case where i want it in a return value of racket_apply.
>
> Nate
>
>
> On Mon, Oct 5, 2020 at 3:26 AM Nate Griswold 
> wrote:
>
>> Note this is from a return value of racket_apply; i called a racket
>> function from c code and want to store the cptr it has returned.
>>
>> Nate
>>
>>
>> On Mon, Oct 5, 2020 at 3:25 AM Nate Griswold 
>> wrote:
>>
>>> What is the best way to access a value that is a cpointer from c code?
>>> Should i convert it to an integer? I have been looking at this for a while,
>>> about an hour, and will continue to look but just thought the list might be
>>> able to answer faster. I know there are chez functions to convert `ptr`s to
>>> integers but those aren't working for me (not an integer error).
>>>
>>> Nate
>>>
>>

-- 
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/CAM-xLPr9dZkz3FkWs_oh-jtcR7bgsuhSgYfTvKHFrCPaqo6GLQ%40mail.gmail.com.


Re: [racket-users] Differences running HtDP programs from DrRacket IDE vs racket command line

2020-10-06 Thread Nick Lee
Thank you very much Robby for the quick reply! I should have mentioned that 
our students are using Beginning Student by setting the Language to that, 
rather than adding #lang htdp/bsl. It appears this makes a difference. So 
the whole file looks like:

;; The first three lines of this file were inserted by DrRacket. They 
record metadata
;; about the language level of this file in a form that our tools can 
easily process.
#reader(lib "htdp-beginner-reader.ss" "lang")((modname file) 
(read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor 
repeating-decimal #f #t none #f () #f)))
(define (quasiquote x) x)
(define (f x) 123)
`(f 888)

Running this file in command line with "racket file.rkt" doesn't show any 
errors for me. I'm using DrRacket 7.8 if it matters.

-- 
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/2b067e72-f364-4f20-a3b7-b0f2e5cc6513n%40googlegroups.com.