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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:12:55+00:00 2026-05-23T12:12:55+00:00

Apparently my teacher believes that even if we don’t have time to learn stuff

  • 0

Apparently my teacher believes that even if we don’t have time to learn stuff (nor enough examples) we should move on, so I now need to know how to make Floyd-Warshall’s and Warshall’s algorithms in clisp.

As I did with prolog, my problem is to generate the adjacency matrix from the graph, in this case it would be a list of lists, e.g.:

((A B) (A C) (A D) (B C) (C D))

That should generate:

((0 1 1 1) (1 0 1 9) (1 1 0 1) (1 9 1 0))

I’ve got this:

(defun floyd(graph)
    (setf l (length graph)) 
    (setf mat (matrix l graph))
)

(defun matrix(l graph)
    (setf matrix (make-array (list l l)))
    (dotimes (i l)
        (dotimes (j l)
            (if (= i j)
                (setf (aref matrix i j) 0)
                (setf (aref matrix i j) ???)
            )
        )
    )
    matrix
)

Any help is greatly appreciated.

Also, and kind of off-topic: If I could solve my own question, should I reply myself for the sake of having an answered question?

  • 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-23T12:12:55+00:00Added an answer on May 23, 2026 at 12:12 pm

    I converted the Wikipedia pseudo-code into Common Lisp with type declarations.
    The return type declaration is non-standard, I used SBCL.
    I guess this won’t run but it might give you an idea how Lisp code is supposed to look like.

    (defparameter *n* 5)
    (defparameter *path*
      (make-array (list *n* *n*)
              :element-type '(unsigned-byte 64)))
    
    
    (defun floyd-warshall (path)
      (declare (type (simple-array (unsigned-byte 64) 2) path)
           (values (simple-array (unsigned-byte 64) 2) &optional))
      (destructuring-bind (y x) (array-dimensions path)
        (unless (= y x)
          (break "I expect a square matrix, not ~ax~a." x y))
        (macrolet ((p (j i)
             `(aref path ,j ,i)))
          (dotimes (k x)
        (dotimes (i x)
          (dotimes (j x)
            (setf (p j i)
              (min (p j i) (+ (p k i)
                      (p j k)))))))))
      path)
    

    Note 1:
    If you have a 3D volume image you should have your indices like this
    (aref vol k j i) where k indexes z, j y and i the x-direction. That way
    in SBCL and presumably all other implementations the slices are consecutive in memory.

    Note 2:
    macrolet can save quite a lot of typing. Also look at the implementation of with-arrays in this beautiful library: git://github.com/nikodemus/raylisp.git/objects/box.lisp

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

Sidebar

Related Questions

Apparently Mac keyboards don't have an Insert key (or maybe they do but I
Apparently I have a unique situation that I can't find help with anywhere. I'm
Apparently I can't move files on different volumes using Directory.Move. I have read that
Apparently there is a database postgres that is created by default on each postgresql
Apparently Matlab load loads the data from a .mat file into the variable that
Apparently many people have run into this problem, but I have yet to be
Apparently I've done something I'm not aware of All my classes now have warnings
Apparently the speed of the C++ linker in Visual Studio 2010 hasn't improved that
Apparently Python only supports 2 minor versions (like 2.X), so that would mean Python
Apparently neither instanceof nor typeof deliver in terms of correctly identifying the type of

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.