Bug in posn-match?

Hi,
In the first input I have an incoming list:
(b e a d f c))
and a list of positions:
(0 2 3 1 4 5)
The posn-match wrongly outputs
(b a d e f c)
but it should be
(b d e a f c)

Why it is so? Am I using a wrong function for this purpose?

All the best!

Ališer

Dear Aliser,

No, it is correct. posn-match will output the position sequence of a list where 0 is the first of the list, meaning in your example:
(b e a d f c)
(0 1 2 3 4 5)
so if you compare the sequence order you gave which is ( 0 2 3 1 4 5), this is correct.
I believe you are misunderstanding the function, or you are looking for something else.

Best
K

Dear Karim and others,

Sorry, you are right! I was working a whole day on one combinatorial issue, so I obviously got confused.

I am using opportunity to explain my combinatorial problem for what I have difficulties to program.
Namely, I have a list at the begin of the combinatorial process
(a b c d e f)
At the end of the process I want to reach constellation
(b d e a f c)
The process consists of gradual fixing the positions of elements according to their position in the final constellation, while the not-yet-fixed group of elements are rotating. Therefore I need another list that defines the order of elements to be fixed, for example:
(() () (a) (a) (a e) (a e d) (a e d) (a e d f) (a e d f) (a e d f b))
[The final constellation is reached when the length - 1 number of elements are fixed.]

So the process should output something like this:

begin constellation:

constellation process ; elements to fix in positions:
a b c d e f ; () - begin constellation
b c d e f a ; ()
c d e (a) f b ; (a)
d e f (a) b c ; (a)
f b (e)(a) c d ; (a e)
b (d)(e)(a) c f ; (a e d)
c (d)(e)(a) f b ; (a e d)
b (d)(e)(a)(f) c ; (a e d f)
c (d)(e)(a)(f) b ; (a e d f)
(b)(d)(e)(a)(f) c ; (a e d f b) - end constellation

[I put the fixed elements in a process in parenthesis for the reason of transparency of the process.]

So if somebody could help me in programming this, I would appreciate it very much!

All the best!

Ališer

Dear Aliser,

this is not really clear to me. Following your example, step 2-3:
Which is which, ie, rotation is not correct and should be (c d e f a b). I understand your parenthesized list, but what should prevail? ie rotation first or the parenthesized list?
And by the way is this list (the parenthesized one) arbitrary?

Best
K

Dear Karim,

I gave an example for the process, but not how it would appear in OM or llisp. (The parenthesis are written only for the purpose to emphasise the elements fixed in positions of the end list. They are irrelevant for programming)
step 1 :
(a b c d e f) since there is an empty list inputed to define the end position of an element (there are no elements to be fixed in position), the whole list is rotated:
Step 2: (b c d e f a)
Step 3: the element a is fixed to its final position 3, and the rest of the list (b c d e f) is rotated (c d e f b) hence giving the resulting list is (c d e a f b)
Step 4: again only a stays fixed in position while the rest of the list (c d e f b) is further rotated (d e f b c), hence giving (d e f a b c)
Step 5: beside a on posn 3, there is also element e fixed at the posn 2. The rest of the list (d f b c) is further rotated (f b c d), so resulting with (f b e a c d)
The process continues further until the end constellation (b d e a f c) is reached.

I hope I give more clear explanation of the process I want to program.

The aim of this is to make a process where elements of a list gradually reaches predefined constellation, whereby it may be controlled in its dynamic. (On the non-fixed parts of a list, instead of rotation there could be applied also random permutation, but I used rotation in order to make the process more transparent for understanding.)

I hope I gave a plausible explanation!

Thank you for your time and help!

All the best!

Ališer

Dear Aliser,

Yes i got this, but still not clearly the problem.
You have a starting list: (a b c d e f) and a target list: (b d e a f c)
Then you have a rotational process, let us say nth times n.
Ok ?
Then this is the part i don’t catch. this list:
(() () (a) (a) (a e) (a e d) (a e d) (a e d f) (a e d f) (a e d f b))
determines the n times of rotation and the fixed places of elmts. Nut is it an arbitrary list, That is what i am asking. ?

Best
K

Dear Karim,
Yes, that is a third (arbitrary) list,
The list (() () (a) (a) (a e) (a e d) (a e d) (a e d f) (a e d f) (a e d f b))
determines the order of elements which are to be be fixed at its positions at each step.
It may be well presented as (nil a e d f b), the list of order of fixing elements to their terminal positions.
Basically the function should have three inputs: begin constellation, end constellation and order-list (order of fixing elements to their position in the end constellation.)

[Of course, the terminal list may be (but doesn’t have to be) also used as the order-list. Than it would look like
(a b c d e f) ; (b)
(b c d e f a) ; (b d)
(b d e f a c) ; (b d e)
(b d e a c f) ; (b d e a)
(b d e a f c) ; (b d e a f)
(b d e a f c) - end constellation]

Many thanks and all the best!

Ališer

Dear Aliser,

Here is a lisp solution:
constellation1.lisp (1.7 KB)

It could be done but in a more complicated way in VP.

Best
K

Dear Karim,

Many, many thanks!

Your functions target-fill and fill-cell from the lisp file you have sent, gave me the solution I was looking for. (I was trying to achieve the same goal with loop using acum and insert lisp-function, but I couldn’t find the solution. Now, I ask myself is it achievable in VP at all. )

With the help of your functions (target-fill and fill-cell) I made a loop that also enables the non fixed part of a list to be passed, rotated or randomly permutated by choice, so I send it in attachment. (If somebody wants to use it, he has to download and install Karim’s lisp- patch from the previous post.)

Karim, thank you once more and all the best!

Ališer

target-constellation-loop.omp (20.1 KB)