473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Lisp(y) A* search implementation

Thanks Jos for that encouragement. :)

Let's see if you really allowed your Lisp(y) knowledge to fade away in midst of those C's and Java's.. Here goes,

If we have following array

Expand|Select|Wrap|Line Numbers
  1. (setf *possible-die-combinations* (make-array '(20 6)
  2. :initial-contents
  3. '((1 3 2 4 5 6)
  4. (1 2 4 5 3 6)
  5. (1 4 5 3 2 6)
  6. (1 5 3 2 4 6)
  7. (2 3 6 4 1 5)
  8. (2 6 4 1 3 5)
  9. (2 4 1 3 6 5)
  10. (2 1 3 6 4 5)
  11. (3 5 6 2 1 4)
  12. (3 6 2 1 5 4)
  13. (3 2 1 5 6 4)
  14. (3 1 5 6 2 4)
  15. (4 6 5 1 2 3)
  16. (4 5 1 2 6 3)
  17. (4 1 2 6 5 3)
  18. (4 2 6 5 1 3)
  19. (5 3 1 4 6 2)
  20. (5 1 4 6 3 2)
  21. (5 4 6 3 1 2)
  22. (5 6 3 1 4 2))))
If you would notice, in every row the set of first and second elements together is unique. For e.g. the first row has (1, 3) and the second row has (1, 2).
Now I want to retrieve a specific row based on this given combination of first and second element. How do I do it?
Apr 8 '08 #1
1 1222
JosAH
11,448 Expert 8TB
hrmph, I only noticed this thread today ...

If those first two numbers are both in a very narrow interval, e.g. [1,6] you can
synthesize a numerical index out of them, e.g 6*(i-1)+j-1 and use that as an index
in another array that stores the original arrays. A nil value would indicate no
array. For 20 arrays out of a possible 36 that isn't too bad.

Otherwise just a Java HashMap comes to mind where the first two numbers
form the key and the array itself forms the value in the Map.

kind regards,

Jos
Apr 9 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
34
by: nobody | last post by:
This article is posted at the request of C.W. Yang who asked me to detail my opinion of Lisp, and for the benefit of people like him, who may find themselves intrigued by this language. The...
82
by: nobody | last post by:
Howdy, Mike! mikecoxlinux@yahoo.com (Mike Cox) wrote in message news:<3d6111f1.0402271647.c20aea3@posting.google.com>... > I'm a C++ programmer, and have to use lisp because I want to use >...
118
by: 63q2o4i02 | last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning Python the past few months and like it very much. A few years ago I had an AI class where we had to use Lisp, and I absolutely...
852
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for...
1
by: Xah Lee | last post by:
Text Processing with Emacs Lisp Xah Lee, 2007-10-29 This page gives a outline of how to use emacs lisp to do text processing, using a specific real-world problem as example. If you don't know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.