Skip to content
View in the app

A better way to browse. Learn more.

Opusmodus

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

sum-list-items*

Featured Replies

very simple, i used something like this for my work... but is there somthing like this in OM?

greetings 

andré

 

 

(defun sum-list-items* (somelists &key (each-step nil))
  (let ((lista (car somelists)) (firstlist (car somelists)))
    (progn
      (setf somelists (loop for x in (rest somelists)
                        collect (setf lista (loop 
                                              for i in lista
                                              for j in x
                                              collect (+ i j)))))
      (if (equal each-step t)
        (append (list firstlist) somelists)
        (car (last somelists))))))
  

(sum-list-items* '((1 0 0 1) (1 0 0 0) (0 0 1 1)))
(sum-list-items* '((1 0 0 1) (1 0 0 0) (0 0 1 1)) :each-step t)


(sum-list-items* '((1 0 8 1) (2 0 0 0) (0 -1 3 1)))
(sum-list-items* '((1 0 8 1) (2 0 0 0) (0 -1 3 1)) :each-step t)

 

(get-count '(a b c d e))
=> 5

Examples:

(setf seql '((2/16 1/16 -1/16) (1/16 2/16 -1/16) (1/4) (1/1)))
(setf seqp '((c4 d4 e4 f4 g4 a4) (bb4 ab4 gb4 e4 db4 c4)))
(setf seqb '((0 1 0 0 1 0 0 1) (1 0 0 1 1 0 0 1)))

The :length keyword, counts how many length notes or length rests are in a sequence.

(get-count seql :length :note)
=> (2 2 1 1)

The sum of all length-notes in the sequence:

(get-count seql :length :note :sum t)
=> 6

The ordinary count:

(get-count seqp)
=> (6 6)

The item keyword, counts a specific item in the sequence:

(get-count seql :item 1/4)
=> (0 0 1 0)

(get-count seqp :item 'bb4)
=> (0 1)

(get-count seqp :sum t)
=> 12

(get-count seqb)
=> (8 8)

(get-count seqb :item 1 :sum t)
=> 7

 

  • Author

i think a different idea!?

in my code:

 

sum first item of all lists

sum second...

sum third...

...

 

but perhaps i'm wrong

  • Author

new version, for LISTS with different-lengths => compensated

 

;;; SUB

(defun compensate-list-lengths (somelists &key (value 0))
  (let ((maxlength (find-max (mapcar 'length somelists))))
    (loop for i in somelists
      when (< (length i) maxlength)
      collect (append i (loop repeat (- maxlength (length i))
                          collect value))
      else collect i)))

                     
;;; MAIN 
                     
(defun sum-list-items (somelists &key (each-step nil))
  (let ((somelists (compensate-list-lengths  somelists))
        (lista (car somelists)) (firstlist (car somelists)))
    (progn
      (setf somelists (loop for x in (rest somelists)
                        collect (setf lista (loop 
                                              for i in lista
                                              for j in x
                                              collect (+ i j)))))
      (if (equal each-step t)
        (append (list firstlist) somelists)
        (car (last somelists))))))

;;;
                     
(sum-list-items '((1 0 4 4 4 4 4 4 0 1) (81 0 0 0) (0 0 1 1 99 200)))
=> (82 0 5 5 103 204 4 4 0 1)
        
                     

 

Create an account or sign in to comment


Copyright © 2014-2026 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.