Jump to content

HelpME .. How can The division of distances IN LIST


hosneyalaa

Recommended Posts

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

 

 

 

 

 

 

Link to comment
Share on other sites

(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)
    )
  )
)

 

  • Thanks 1
Link to comment
Share on other sites

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

 

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...