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

The Archive Base Latest Questions

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

To implement depth-first search in a grid, I wrote a function like this (define

  • 0

To implement depth-first search in a grid, I wrote a function like this

(define (expand dim node visited obs)
  (not-in (neighbor dim obs node) visited))

The function dfs is

(dfs dim obs visited fringe path goal)

The only appearance of expand in dfs is

(expand dim (car fringe) visited obs)

And I called dfs using

(dfs '(5 5) '((2 2) (3 2)) '((2 1)) '((1 1) (3 1)) '((2 1)) '(4 5))

dim is the dimension of the grid, obs is a list of the blocked positions in the grid.

When I call expand by hand it works perfectly. But when it’s called in dfs, it says “expand: expects 1 argument, given 4: ‘(5 5) ‘(1 1) ‘((2 1)) ‘((2 2) (3 2) (3 4) (4 4) (5 4))“

However, if I change the position of arguments of expand, e.g. put obs as the second argument,

(define (expand dim obs node visited)
  (not-in (neighbor dim obs node) visited))

and modify dfs and my callings correspondingly, then the error won’t appear and everything works well. Then next time I launch DrRacket and paste the modified code into it, the same error reappears. If I swap obs back, it works well again…
What on earth is happening here?! 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-30T03:33:51+00:00Added an answer on May 30, 2026 at 3:33 am

    expand is an awfully generic name that might have a definition somewhere else. Rename your funciton to dfs-expand and see if this fixes it.

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

Sidebar

Related Questions

I am trying to implement the depth first search algorithm into my game. I
Suppose you have to implement Graph class, containing some algorithms, using dfs (depth-first search).
I am trying to implement a modified parallel depth-first search algorithm in Erlang (let's
I'm trying to implement something like this: <div> <table> <thead> <tr> <td>Port name</td> <td>Current
When does pruning stop being efficient in a depth-first search? I've been working on
Suppose that I have a tree to traverse using a Depth First Search, and
My function to implement the search is below. The issue I have is I
How will you implement a tree structure in C for navigation in preorder depth-first
This a conceptual question on how one would implement the following in Lisp (assuming
I'm trying to implement the technique described at : Compositing Images with Depth .

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.