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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:30:56+00:00 2026-05-26T03:30:56+00:00

I think this is going to be a vague question because I don’t know

  • 0

I think this is going to be a vague question because I don’t know exactly what I am doing in the first place but here it goes.

I have to do a towers of hanoi problem in common lisp using lists. Basically a function takes a list of strings (names) and then moves them from peg A to peg C using peg B for storage, keeping them in the same order as they were in the list.

I have never used lisp before and I find the syntax very hard to understand.
This is my code so far
goo function is the hanoi work

(defparameter A '())
(defparameter B '())
(defparameter C '())


(defun findPeg (p1 p2) (cond ((= 0 (- 3 p1 p2))A)  
    ((= 1 (- 3 p1 p2))B) ((= 2 (- 3 p1 p2))C)))

(defun getnum (x) (cond ((equalp x A) 0)((equalp x B)1)((equalp x C) 2)))

(defun hanoi (x) (defparameter A x) (setlength A)(goo len A C B))

(defun setlength(x) (defparameter len (list-length x)))


(defun goo (leng from to via) 

    (cond ((= leng 1)(push (pop A) C)) ;base case


((goo (1- leng) from via to)(push (pop A)  B) ;say/do something i think


((goo (1- leng) via to from)(push (pop B) C) ;say/do something i think


))))

My problem is with the recursive calls. I am very confused as to what exactly I should be doing. I know I obviously have to move the first string in the first list to another peg, but I don’t know which peg or even how to manipulate the lists. I feel like I should be using the variables that were passed into the goo function, but I cant figure out how to edit them because when I change them in the function the variables outside do not change.

Right now I am running into the error

* – SYSTEM::%EXPAND-FORM: (GOO (1- LENG) FROM VIA TO) should be a lambda expression

This is a recursive call so I don’t know why it is saying that.

Basically I just want some tips or tricks on where do continue or ever where to restart because I don’t even know if my approach is a good one.
Anything is 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-26T03:30:57+00:00Added an answer on May 26, 2026 at 3:30 am

    First off, using defparameter inside a DEFUN is almost never the right thing to do.

    If you want to have a lexically-scoped variable, use LET (or simply name your formal parameters as you’d like them named).

    Second, you have something on the form ((fun arg ..) (fun arg ...)) inside your GOO function. You want to lose the outermost parentheses.

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

Sidebar

Related Questions

I think I already know the answer, but I'm going to ask the question
I'm sorry this question is going to be a bit vague because I'm not
I think this is going to be one of those simple-when-you-see-it problems, but it
I think the answer to this is no going in, but I could use
I think this must be a stupid question, but why do the results of
I know this is a similar question to one already asked, but I was
This is a two part question, but I want to make sure the first
I think this is specific to IE 6.0 but... In JavaScript I add a
I think this is a multi-part question, so bear with me. Currently all of
I think this must be simple but I can't get it right... I have

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.