hosneyalaa Posted December 16, 2020 Posted December 16, 2020 Hello all Please help If I have the following list distance (SETQ ALIT '(0 12.20 33.40 51.89)) I want a division between distance IF (A - B) < 15 >>>> (A - B)/3 IF (A - B) > 15 >>>> (A - B)/4 IF (12.20 - 0) < 15 >>>> (12.20 - 0) = 12.20 / 3 = 4.06 >>>> (0 4.06 8.13 12.20) IF (33.40 - 12.2) > 15 >>>> (33.40 - 12.2) = 21.2 / 4 = 5.3 >>>> (12.20 17.50 22.80 28.10 33.40) Finally, I want the distance list in this way (SETQ ALITOUT '(0 4.06 8.13 12.20 17.50 22.80 28.10 33.40 38.02 42.64 47.26 51.89)) Thanks in advance to everyone Quote
Stefan BMR Posted December 16, 2020 Posted December 16, 2020 (cons (car alit) (apply 'append (mapcar '(lambda (a b / d n r) (setq d (- b a) n (if (< d 15.0) 3 4) d (/ d n) ) (repeat n (setq r (cons b r) b (- b d))) r ) alit (cdr alit) ) ) ) 1 Quote
hosneyalaa Posted December 16, 2020 Author Posted December 16, 2020 5 minutes ago, Stefan BMR said: (cons (car alit) (apply 'append (mapcar '(lambda (a b / d n r) (setq d (- b a) n (if (< d 15.0) 3 4) d (/ d n) ) (repeat n (setq r (cons b r) b (- b d))) r ) alit (cdr alit) ) ) ) Thank you very much, Mr. Stefan BMR It works great Quote
Recommended Posts
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.