For Programmers: Free Programming Magazines  


Home > Archive > Prolog > May 2006 > List to grid reference..









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author List to grid reference..
brianbasquille@gmail.com

2006-05-01, 7:03 pm

Bit of a simple question here, i'd say!

Say i have a list containing two numbers ( e.g [1,2] ). How do i simply
convert this to (1,2)? To show a grid reference.

I know how to convert it the opposite way - i.e (1,2) to [1.2] is done
like so: (X,Y) = [X,Y].

... where X = 1, Y = 2. This will work without problems but when i try:
[X,Y] = (X,Y).

This won't work.

PS - am using SWI-Prolog.

Nick Wedd

2006-05-02, 8:02 am

In message <1146500637.376587.267430@y43g2000cwc.googlegroups.com>,
brianbasquille@gmail.com writes
>Bit of a simple question here, i'd say!
>
>Say i have a list containing two numbers ( e.g [1,2] ). How do i simply
>convert this to (1,2)? To show a grid reference.


I don't understand the question (and judging from the lack of response,
others don't either).

What kind of thing do you think (1,2) is? Technically it is a term
whose principal functor is a comma, and with two arguments, which could
more clearly be written ,(1,2). But I suspect that is not what you
mean.

>I know how to convert it the opposite way - i.e (1,2) to [1.2] is done
>like so: (X,Y) = [X,Y].


I don't see how that could work. Can you show us it working in context?
And when you say [1.2], do you mean it, or is it a typo for [1,2]?

>.. where X = 1, Y = 2. This will work without problems but when i try:
>[X,Y] = (X,Y).
>
>This won't work.


[X,Y] = (X,Y)
and
(X,Y) = [X,Y]
should have exactly the same effect (and that effect is not likely to be
what you want).

Nick
--
Nick Wedd nick@maproom.co.uk
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com