Post Reply 
HP49-HP50 : when {list of repeated solutions} —> {list with no rep. sol}
12-21-2022, 10:11 AM (This post was last modified: 12-21-2022 10:22 AM by Gil.)
Post: #1
HP49-HP50 : when {list of repeated solutions} —> {list with no rep. sol}
Suppose that I find the following solution set:
{ [ 1 1 '1/3' 0 0 1 '26/3' ]
[ 1 1 '1/3' 0 0 1 '26/3' ]
[ 1 1 '1/3' 0 0 1 '26/3' ]
[ 5 1 '1/3' 0 0 1 '26/3' ]
[ 5 1 '1/3' 0 0 1 '26/3' ]
[ 5 1 '1/3' 0 0 1 '26/3' ]
[ 5 1 '1/3' 0 0 1 '26/3' ]
[ 5 1 '1/3' 0 0 1 '26/3' ]
[ 10 1 '1/3' 0 0 1 '26/3' ]
[ 20 1 '1/3' 0 0 1 '26/3' ]
[ 30 1 '1/3' 0 0 1 '26/3' ]
[ 30 1 '1/3' 0 0 1 '26/3' ] }.

Suppose now that I want the corresponding list without having the repeated vector in my list:
{ [ 1 1 '1/3' 0 0 1 '26/3' ]
[ 5 1 '1/3' 0 0 1 '26/3' ]
[ 10 1 '1/3' 0 0 1 '26/3' ]
[ 20 1 '1/3' 0 0 1 '26/3' ]
[ 30 1 '1/3' 0 0 1 '26/3' ] }

My solution is using SREPL.

First I put each solution element, repeated or not, as a string like :

{"[ 1 1 '1/3' 0 0 1 '26/3' ]"
"[ 1 1 '1/3' 0 0 1 '26/3' ]"
"[ 1 1 '1/3' 0 0 1 '26/3' ]"
"[ 5 1 '1/3' 0 0 1 '26/3' ]"
"[ 5 1 '1/3' 0 0 1 '26/3' ]"
"[ 5 1 '1/3' 0 0 1 '26/3' ]"
"[ 5 1 '1/3' 0 0 1 '26/3' ]"
"[ 5 1 '1/3' 0 0 1 '26/3' ]"
"[ 10 1 '1/3' 0 0 1 '26/3' ]"
"[ 20 1 '1/3' 0 0 1 '26/3' ]"
"[ 30 1 '1/3' 0 0 1 '26/3' ]"
"[ 30 1 '1/3' 0 0 1 '26/3' ]" }

and save that big list of string.solutions under sol.list.

Then use the following program:
\<< sol.list \->STR \-> s
\<< sol.list SIZE 1
FOR i s sol.list i GET DUP UNROT "" SREPL DROP + 's' STO -1
STEP "\|>" s + "\|>" "{" SREPL DROP "\|>" + "\|>" "}" SREPL DROP OBJ\-> OBJ\-> HALT SWAP DROP 1 - \->LIST
\>>
\>>

Or equivalently
« sol.list —>STR —> s
« sol.list SIZE 1
FOR i s sol.list i GET DUP UNROT "" SREPL DROP + 's' STO -1
STEP "AAAAA" s + "AAAAA" "{" SREPL DROP "AAAAA" + "AAAAAA" "}" SREPL DROP OBJ—> OBJ—> SWAP DROP 1 - —>LIST
»
»

My question:
Is there a better or simpler way to get the same result, without using this string manipulation & also not using any kind of special Library?

Thanks in advance for your insight.

Gil Campart
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP49-HP50 : when {list of repeated solutions} —> {list with no rep. sol} - Gil - 12-21-2022 10:11 AM



User(s) browsing this thread: 1 Guest(s)