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.

integer-to-binary-lengths*

Featured Replies

perhaps there's a OM-solution... in this case it's to hard to find... (search-engine?)

otherwise...

 


(defun integer-to-binary-lengths* (alist)
  (loop for i in alist
    when (> (abs i) 1)
    append (append (list 1) (loop repeat (- (abs i) 1)
                      collect 0))
    else collect 1))
  

(integer-to-binary-lengths* '(2 2 2 1 1 4 4 4 4))
(integer-to-binary-lengths* '(6 4 8 5 2 1 10 2))

 

  • Author

it's not decimal-to-binary!!! another idea...

 

for example...

6 => 1 0 0 0 0 0 = a "1" and 5 times a "0")

I've made this long time ago, bit different but may be also of interest, this function use a specs of number of "1" and "0" in input:

 

;;; GEN-BINARY_INTEGER
(defun gen-binary-integer (one-list zero-list &key (flatten t))
  (do-verbose
      ("gen-binary-integer")
  (if flatten
    (flatten
     (loop
       for i in one-list
       for o in (gen-trim (length one-list) zero-list) 
       collect 
       (append
        (gen-repeat i '(1))
        (gen-repeat o '(0))
     )))
    (loop
       for i in one-list
       for o in (gen-trim (length one-list) zero-list) 
       collect 
       (append
        (gen-repeat i '(1))
        (gen-repeat o '(0))
     )))))

#| USAGE
(gen-binary-integer '(3 4 3 2 4 2 5) '(1 1 3))
=> (1 1 1 0 1 1 1 1 0 1 1 1 0 0 0 1 1 0 1 1 1 1 0 1 1 0 0 0 1 1 1 1 1 0)

(gen-binary-integer '(3 4 3 2 4 2 5) '(1 1 3) :flatten nil)
=> ((1 1 1 0) (1 1 1 1 0) (1 1 1 0 0 0) (1 1 0) (1 1 1 1 0) (1 1 0 0 0) (1 1 1 1 1 0))

(setf intg '(3 2 4 5 3))
(setf zero-k '(1 2 1 3))

(gen-binary-integer intg zero-k)

=> '(1 1 1 0 1 1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 0 1 1 1 0)

|#

S.

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

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.