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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:05:12+00:00 2026-05-11T22:05:12+00:00

I want to access a n-dimensional vector but somehow (empty? ‘()) keeps returning false.

  • 0

I want to access a n-dimensional vector but somehow (empty? ‘()) keeps returning false.

;; access n dimensional vectors
;; (access-nd vector a-list-of-numbers) -> element
;; (access-nd (vector (vector ‘x ‘y) ‘a ‘b)) 0 1 ) -> x

(define (access-nd avector . alist)
  (cond
    ((and (not(empty? alist)) (vector? avector))
     (vector-ref (access-nd avector (rest alist)) (first alist)))
    (else avector)))

Please Help.

Edit: CORRECTED CODE

(define (access-nd avector . alist)
  (cond
    ((and (not(empty? alist)) (vector? avector))
     (apply access-nd (vector-ref avector  (first alist)) (rest alist)))
    (else avector)))
  • 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-11T22:05:12+00:00Added an answer on May 11, 2026 at 10:05 pm

    Most likely, that one line should read:

         (vector-ref (apply access-nd avector (rest alist)) (first alist)))
    

    Without the “apply”, alist will never be empty. Here’s why:

    In the definition of access-nd the alist parameter is an optional parameters list; it’s separated with a dot from normal positional parameters. This means access-nd can be called with 1-n parameters. Any parameters after the first one are collected to a list and bound to alist. For example, a call like

    (access-nd v 1 2 3) 
    

    will cause alist to be bound to the list (1 2 3). Similarly, this call in your original code:

    (access-nd avector (rest alist))
    

    will cause alist to be bound to a list with one element. That’s why alist will never be empty.

    Scheme’s apply, on the other hand, takes a list of arguments as the last parameter and calls the function as if they were passed to it in the normal way.

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

Sidebar

Ask A Question

Stats

  • Questions 514k
  • Answers 514k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You will need to fake a POST HTTP-Request to the… May 16, 2026 at 6:11 pm
  • Editorial Team
    Editorial Team added an answer Here is one way to do it d = {(15,21):… May 16, 2026 at 6:11 pm
  • Editorial Team
    Editorial Team added an answer You should replace the ArrayList with an ObservableCollection<string> which will… May 16, 2026 at 6:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I want to access the 'url' attribute in the media:content element below. I am
I have what amounts to a multi-dimensional array. int[][][] MyValues; What I want is
How do I access the first level key of a two-dimensional array using a
i want to access a javascript function which resides in a script file from
I want to access a resource like a String or a Drawable by its
I want to access id of current logged user name of current logged user
I want to access a GWT service from a Python script, so I want
I want to access a URL of another website from one of my models,
I want to access a web service over HTTPS. I have been given a
I'm trying to reduce a high-dimension dataset to 2-D. However, I don't have access

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.