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 8772117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:57:43+00:00 2026-06-13T17:57:43+00:00

I just started learning lisp in my class. I’m doing a homework assignment in

  • 0

I just started learning lisp in my class. I’m doing a homework assignment in which I have to program a few very basic functions using some primitives operations such as car, cdr, cons, append, reverse, atom, eq, equal, and null.

So here is my code so far:

(defun union2 (l1 l2)
  (cond ((null l1) l2)
        ((member((car l1) l2)) (union2((cdr l1) l2)))
        (t (cons (car l1) (union2((cdr l1) l2)))))
  )

When I try to run my test:

(union2 '(5 7 2 3 1) '(3 2 4 6 9))

I get an “Error: Illegal function object: (car l1).” I was under the impression that I was writing the code correctly. What am I doing wrong?
Thank you for your time.

  • 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-13T17:57:45+00:00Added an answer on June 13, 2026 at 5:57 pm

    Try using a compiler, like SBCL:

    * (defun union2 (l1 l2)
      (cond ((null l1) l2)
            ((member((car l1) l2)) (union2((cdr l1) l2)))
            (t (cons (car l1) (union2((cdr l1) l2)))))
      )
    ; in: DEFUN UNION2
    ;     ((CAR L1) L2)
    ; 
    ; caught ERROR:
    ;   illegal function call
    
    ;     (MEMBER ((CAR L1) L2))
    ; 
    ; caught WARNING:
    ;   The function was called with one argument, but wants at least two.
    
    ;     ((CDR L1) L2)
    ; 
    ; caught ERROR:
    ;   illegal function call
    
    ;     (UNION2 ((CDR L1) L2))
    ; 
    ; caught WARNING:
    ;   The function was called with one argument, but wants exactly two.
    
    ;     ((CDR L1) L2)
    ; 
    ; caught ERROR:
    ;   illegal function call
    
    ;     (UNION2 ((CDR L1) L2))
    ; 
    ; caught WARNING:
    ;   The function was called with one argument, but wants exactly two.
    ; 
    ; compilation unit finished
    ;   caught 3 ERROR conditions
    ;   caught 3 WARNING conditions
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning Common Lisp a few days ago, and I'm trying to
I've started learning Lisp recently and wanted to write a program which uses gtk
I just started learning Objective-C and OOP ... so I have very stupid question
We just started learning about class inheritance and attribute lookup in python. I have
We just started learning windows programming in C++. We have to make a program
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
Just started learning Haskell. I have an empty source file with this inside: pe
I just started learning RoR. This is my /app/trip_controller.rb file class TripController < ApplicationController
I just started learning Backbone.js, and have been working on (what else) a simple
I just started learning Zend. I managed to get the basic working (using zf

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.