Jump to content

list sum


Recommended Posts

2 hours ago, opmo said:

Do you mean: get-count

No.
The function which does something like this:

;; scale all numbers of lst that the sum of lst is 25
(setf lst '(1 2 3 4 5))
(setf list-sum (sum lst))
(setf scale 25)
(setf result1
(loop for i in lst
      collect (* 1.0 (* scale 
                         (/ i list-sum)))))
;; test (sum result1)
(setf result2
(loop for i in lst
      collect (round
               (* 1.0 (* scale 
                         (/ i list-sum))))))
;; test (sum result2)

 

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.

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

Important Information

Terms of Use Privacy Policy