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

  • SEARCH
  • Home
  • 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 7706549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:09:10+00:00 2026-06-01T00:09:10+00:00

First time stackoverflow user but occasional lurker, hope you guys can help me out.

  • 0

First time stackoverflow user but occasional lurker, hope you guys can help me out.

So the first part of my assignment is to drop all ‘leading zeros’ in a list.

ex: (0 0 0 0 0 1 0 1 0 1) -> (1 0 1 0 1)

To do this, I thought to use an IF statement to check whether the first element was a 0 or not, and to recursively call the rest of the list until the there were no more leading zeros. As I have basically no idea how to program in Scheme, through searching the internet, I came up with what you see below. However when I run it, DrRacket tells me there are no arguments- I assume this either a syntactical error.. or more likely, I have no idea what I’m doing. So, if you could help me out, I’d really appreciate it!

    >(define zz
    >  (lambda (n)
    >    (if (= (car (n)) 0)
    >        (zz (cdr (n)))
    >        ((n)))))
    >
    >(remove '(0 0 0 0 1 0 1 0))

The error I get in DrRacket is:

“procedure application: expected procedure, given: (0 0 0 0 1 0 1 0) (no arguments)”

Again, thanks a lot! (P.S. Sorry if the formatting is a little odd…)

EDIT

Okay, changing up some stuff, I now get a “expects type as 1st argument, given: (0 0 0 0 0 1 0 1 0); other arguments were: 0” error flagged at my if statement.

    >(define zz
    >  (lambda n
    >    (if (= (car n) 0)   <----- here
    >        (zz(cdr n))
    >        (n))))

EDIT 2

    >(define zz
    >  (lambda (n)
    >    (if (= (car n) 0)
    >        (zz (cdr n))
    >        n)))

It works, thank you very much!

  • 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-06-01T00:09:11+00:00Added an answer on June 1, 2026 at 12:09 am

    (num) is not correct – you’re trying to call 42 or whatever as a command. (Also, your if syntax is off; you may want to do read more code to get a better feel for the syntax).

    This should compile:

    (define remove
      (lambda (num)
        (if (= (car num) 0)
          (remove (cdr num))
          num)))
    

    Parenthesis in Lisp are for calling functions, unless used in quotes.


    Okay, the OP asked about a general rundown of the syntax for Scheme.

    • a – A symbol, which is looked up by the evaluator and substituted for its value. Some symbols (such as 42) evaluate to themselves.

    • 'a – This “quotes” the symbol and transforms it into (quote a). quote prevents its argument from being evaluated – instead, the value a is returned. Not the string “a”, not the result of looking up a, a itself. This also works for lists ('(1 2 3))

    • (if <expr> <true-value> <false-value>) – This evaluates <expr>, and sees if its value is truthy or not, and executes the corresponding value.

    • (cond (<expr> <true-value>)
      ...
      (else <false-value>))
      – This runs though its arguments, and evaluates the car of it to see if it is true. If it is, the value of evaluating the cdr is returned. Otherwise, it skips to the next value.

    • (define <name> <expr>) – Sets the value of evaluating the second argument to the name of the first argument.

    • (lambda <arg-list> <body>) – Creates a procedure which is the result of binding the arguments passed in to the names present in the second argument and evaluating the third argument.

    • (<func> <arg1> <arg2> ... <argn>) – If the evaluator finds out that none of the above patterns match, then it calls the car of the list as a function, with the arguments in the cdr.

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

Sidebar

Related Questions

First time user of stackoverflow, but I have followed its development over on Coding
first time SO user :) I know that I can format a number like
this is my first time on Stackoverflow so any help will be appriciated. I
This is my first time posting to stackoverflow, but these threads have helped me
This is my first time using stackoverflow. I've been unable to find out the
this is my first time posting on StackOverflow but this site is awesome. Thanks
This is my first time on StackOverflow though I read Coding Horror quite often.
first time posting in StackOverflow. :D I need my software to add a couple
I'm a long running fan of stackoverflow, first time poster. I'd love to see
first time posting here. I'm using a loop to create 3 buttons, but my

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.