Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3989214
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:20:45+00:00 2026-05-20T06:20:45+00:00

I have written the following syntax rule: (define-syntax match-rewriter (syntax-rules () ((_ (patt body)

  • 0

I have written the following syntax rule:

(define-syntax match-rewriter  
  (syntax-rules ()
    ((_ (patt body) ...)
     (λ (x) (match x (patt body) ... (_ x))))))

which is essentially match-lambda except that it returns its argument if no match is found rather than throwing an exception.

Now I want to write a function, let_as_lambda, that will take strings of source code as input and rewrite the let statements as the new let_as_lambda function. This is what I have:

(define let_as_lambda  
  (match-rewriter (`(let((,<var> ,<val>)) ... ,<expressions>)
                   `((lambda (,<var> ...) ,<expressions>) ,<val> ...))))

It is clearly wrong as:

(let_as_lambda '(let((x 3)) (+ x 2)))

returns:

'((λ ((x) ...) (+ x 2)) (3) ...)

still showing the ellipses and with the “3” in parentheses. I believe my problem is that I don’t understand the proper usage of the symbols `, ., and , in pattern matching.

If someone could show me the correct way to do this it would be greatly appreciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:20:45+00:00Added an answer on May 20, 2026 at 6:20 am

    You’re probably confused because you use two different pattern matching tools. The first is what you get with syntax-rules and the second is match. They seem close enough but there are some important differences — and in this case, the main problem is that unlike syntax-rules, you cannot use ... in quasi-quoted results of a match. So to deal with lists of matched values you need to use unquote-splicing (or ,@) and other functions like map etc. For example, compare the results of these two expressions:

    (match '(1 2 3) [`(,x ...) `(foo ,x ...)])
    (match '(1 2 3) [`(,x ...) `(foo ,@x)])
    

    As a side note, it would be nice if the usual quasi-quote would do what you want, but for a complete solution it needs to be possible with simple functions too — and that complicates the whole thing (uses of ... will need to translate to apply).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written following code which generates a browse and upload button.i want to
I'm getting started with cucumber, and I have written the following step definition, which
I have written the following simple test in trying to learn Castle Windsor's Fluent
I have written something that uses the following includes: #include <math.h> #include <time.h> #include
I have written a KornShell (ksh) script that sets an array the following way:
I have the following in a program (written in VB.NET): Imports Microsoft.Office.Interop.Excel Public Class
(All of the following is to be written in Java) I have to build
I have written a ruby script which opens up dlink admin page in firefox
I have written an AppleScript which when supplied with a Windows network link, will
I have written the following trigger in SQL server: create trigger test_trigger on invoice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.