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

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?

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 >

Re: [racket-users] Pattern Matching

2020-09-29 Thread Wesley Bitomski
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,

Re: [racket-users] Pattern Matching

2020-09-28 Thread George Neuner
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

Re: [racket-users] Pattern matching as computation

2019-06-27 Thread David Storrs
Oh, neat. Thank you, Sorawee. On Thu, Jun 27, 2019 at 7:26 PM Sorawee Porncharoenwase < sorawee.pw...@gmail.com> wrote: > If you want only one match, it seems what you really want is ~seq-like > form from syntax/parse. E.g., > > #lang racket > > (require syntax/parse) > > (define ->value

Re: [racket-users] Pattern matching as computation

2019-06-27 Thread Sorawee Porncharoenwase
If you want only one match, it seems what you really want is ~seq-like form from syntax/parse. E.g., #lang racket (require syntax/parse) (define ->value syntax->datum) (define (apply-lift op args) (datum->syntax #f (apply op (->value args (syntax-parse (vector 1 2 3 4) [#(a {~and

Re: [racket-users] Pattern matching as computation

2019-06-27 Thread David Storrs
On Thu, Jun 27, 2019 at 5:13 PM Eric Griffis wrote: > On Thu, Jun 27, 2019 at 11:56 AM David Storrs > wrote: > > > > Suppose instead I wanted to have a pattern like so (this does not work): > > > > (match (vector 1 2 3 4) > > [(vector a (app + b ..2 x) c) (list a b c x)] > > ; => '(1 (2 3) 4

Re: [racket-users] Pattern matching as computation

2019-06-27 Thread Eric Griffis
On Thu, Jun 27, 2019 at 11:56 AM David Storrs wrote: > > Suppose instead I wanted to have a pattern like so (this does not work): > > (match (vector 1 2 3 4) > [(vector a (app + b ..2 x) c) (list a b c x)] > ; => '(1 (2 3) 4 5)) ; NB: does not work We have a few problems here. The pattern

Re: Re: [racket-users] Pattern Matching in Macros | Meaning of dot

2016-03-14 Thread Jens Axel Søgaard
Yes, lambda expression have an implicit begin in the body. > (begin . (1 2 3)) 3 > (begin (1 2 3)) application: not a procedure; expected a procedure that can be applied to arguments given: 1 arguments...: Here (begin . (1 2 3)) is the same as (begin 1 2 3). The

Re: Re: [racket-users] Pattern Matching in Macros | Meaning of dot

2016-03-14 Thread Pedro Caldeira
Does that mean that lambda expressions have an implicit (begin …) block in them? (begin ((displayln 1) (displayln 2) (displayln 3))) leads to an error (begin . ((displayln 1) (displayln 2) (displayln 3))) displays to 1 2 3 Thank you for the detailed explanation I think I get it now. > On 13

Re: [racket-users] Pattern Matching in Macros | Meaning of dot

2016-03-13 Thread Pedro Caldeira
>Imagine (_ (foo x y z) (displayln x) (displayln y) (displayln z)) as the >actual syntax. The .body will be bound to the sequence of three diaplaylns and >this sequence will become the body of the lambda in the expansion. So in this case body will be bound to the list ((displayln x) (displayln

Re: [racket-users] Pattern Matching in Macros | Meaning of dot

2016-03-13 Thread Jens Axel Søgaard
The cons cell constructed by (cons 1 2) is normally printed as (1 . 2). The list created by (list 1 2 3) could also be created as (cons 1 (cons 2 (cons 3 '(. It could be printed as (1 . (2 . (3 . (. Normally lists are simply printed as (1 2 3) though. Notice that (1 . (list 2 3)) is the

RE: [racket-users] Pattern Matching in Macros | Meaning of dot

2016-03-13 Thread Jos Koot
Consider (define/memoized (a b c d) form0 form1 form2) . body allows the body to consist of more than one form. Without the dot, syntax define/memoized would accept bodies of one form only, that is (define/memoized (a b c d) form0) would match, but (define/memoized (a b c d) form0 form1 form2)

Re: [racket-users] Pattern Matching in Macros | Meaning of dot

2016-03-13 Thread Matthias Felleisen
> On Mar 13, 2016, at 11:05 AM, Pedro Caldeira > wrote: > > Hello everyone, > > Since I've discovered the concept of metaprogramming I've been quite > interested in Racket and its syntax extension capabilities. > > While searching for a memoization syntax