Jump to content
EniSan

Possible paths and ordered according to criteria

Recommended Posts

marko_ribar

Still no one interested... My lisp-sub function is ready and working well... I don't want to be boring, it's not imperative, but if I am in your position I'd think some compensation and reply to mail... It can be anything you find adequate - maybe another lisp, some small program you often use, or maybe something third, but it must be equal value like my ready sub routine...

Share this post


Link to post
Share on other sites
EniSan

Hello friends, I solved the problem myself. Even so, I appreciate the opinions and attempts. I will share the code I developed with you. Just run and the expected result is achieved. The only problem that I haven't been able to completely solve yet is the need for the n_iterations variable. I would like to get help from you. I don't want to change its value when the L list changes to a larger one. See you later.

 

(setq S (list 3.0 0.0 1.5))
	(setq F (list 2.5 4.5 3.0))
	(setq L 
		(list 
		(list (list 3.0 0.0 1.5) (list 0.0 2.5 1.5) (list 3.90512))
		(list (list 0.0 2.5 1.5) (list 0.0 2.5 3.0) (list 2.5 3.5 3.0) (list 4.19258)) 		
		(list (list 3.0 0.0 1.5) (list 5.0 0.0 1.5) (list 5.0 2.5 1.5) (list 4.5)) 	
		(list (list 5.0 2.5 1.5) (list 2.5 3.5 3.0) (list 3.08221)) 		
		(list (list 5.0 2.5 1.5) (list 5.0 6.5 1.5) (list 4.0)) 		
		(list (list 2.5 3.5 3.0) (list 5.0 2.5 1.5) (list 3.08221)) 
		(list (list 2.5 3.5 3.0) (list 2.5 4.5 3.0) (list 1.0)) 
		(list (list 2.5 3.5 3.0) (list 0.0 2.5 3.0) (list 0.0 2.5 1.5) (list 4.19258)) 
		(list (list 5.0 6.5 1.5) (list 5.0 2.5 1.5) (list 4.0)) 
		(list (list 5.0 6.5 1.5) (list 5.0 6.5 3.0) (list 2.5 5.5 3.0) (list 4.19258)) 
		(list (list 5.0 6.5 1.5) (list 5.0 6.5 0.0) (list 2.0 7.5 0.0) (list 2.0 7.5 0.3) (list 4.96228)) 
		(list (list 2.5 5.5 3.0) (list 0.8 6.0 0.0) (list 3.48425)) 
		(list (list 2.5 5.5 3.0) (list 5.0 6.5 3.0) (list 5.0 6.5 1.5) (list 4.19258)) 
		(list (list 2.5 5.5 3.0) (list 2.5 4.5 3.0) (list 1.0)) 
		(list (list 2.0 7.5 0.3) (list 2.0 7.5 0.0) (list 5.0 6.5 0.0) (list 5.0 6.5 1.5) (list 4.96228)) 
		(list (list 2.0 7.5 0.3) (list 2.0 7.5 0.0) (list 0.8 6.0 0.0) (list 2.22094)) 
		(list (list 0.8 6.0 0.0) (list 2.5 5.5 3.0) (list 3.48425)) 
		(list (list 0.8 6.0 0.0) (list 2.0 7.5 0.0) (list 2.0 7.5 0.3) (list 2.22094))
		)
	)
		
	;;;;;;
	(setq L_backup L)
	(setq n_iterations 8)
	(setq new_L nil)
	(setq path_select nil)
	
	(defun is_in(small_list big_list / posit answ)
		(setq posit
			(vl-string-search
				(vl-string-trim "\()" 
					(vl-princ-to-string small_list)								
				) 
				(vl-princ-to-string big_list)
			)
		)
		(if (numberp posit) (setq answ t) (setq answ nil))
	)	
	
	(repeat n_iterations
		(foreach path_AB L
			(setq last_end (nth 1 (reverse path_AB)))
		
			(foreach element L_backup
				(setq first_end (car element))
				(setq twin (append (cdr (reverse element)) (list (last element))))
				
				(if (and (equal (car path_AB) S) (equal first_end last_end))
					(progn
						(setq join (list (append path_AB element)))
						(if (and 
								(not (is_in twin path_AB))
								(not (is_in element path_AB))
								(not (is_in join new_L))
							)
							(progn
								(setq new_L (append new_L join))
								(setq L (append L join))
							)
						)
					)
				)
			)
		)
	)
	
	(foreach item new_L
		(if (equal F (nth 1 (reverse item)))
			(setq path_select (append path_select (list item)))
		)
	)
	;;;;;;
	

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...