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

Featured Replies


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;how to split randomly a number into "n-parts"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun rnd-split-number (n &key (total-sum 1.0))
  (let ((values))
    (setq values (loop repeat (- n 1)
                   with val-a = total-sum
                   with val-b
                   collect (setq val-b (random val-a))
                   do (setq val-a (- val-a val-b))))
    (append values (list (- total-sum (sum values))))))


;; examples
(rnd-split-number 5 :total-sum 1.8)

=> (0.26645982 1.47964 0.014375878 0.014122969 0.025401235)

(rnd-split-number 3 :total-sum 9.8)

=> (5.1533704 1.7459779 2.900652)

 

With SEED:

(defun rnd-division (n &key (sum 1.0) seed)
  (do-verbose ("rnd-division")
    (rnd-seed seed)
    (let ((values
           (loop repeat (- n 1)
             with a = sum
             with b
             collect (setf b (random* a :seed (seed)))
             do (setf a (- a b)))))
      (append values (list (- sum (sum values)))))))

(rnd-division 5 :seed 5)
=> (0.0052785673 0.09165209 0.06036401 0.65849 0.1842153)

(rnd-division 3 :sum 9.8 :seed 87)
=> (3.9023237 0.8761092 5.0215673)

 

To add seed to the function use RANDOM* OM function.

Create an account or sign in to comment


Copyright © 2014-2025 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

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.