Jump to content
Sign in to follow this  

alternative "binary-layer" function

Recommended Posts

here is a sketch for an alternative "binary-(or element-)layer-FUNCTION


(defun element-layer (lists &key (rnd nil))
  (let ((lists (if (null rnd)
                 (rnd-order lists :list t))))
      (loop for x in (rest lists)
        with list = (car lists)
        collect (setf list (loop for i in list
                             with cnt = 0 
                             when (equal i 0)
                             collect (nth cnt x)
                             and do (incf cnt)
                             else collect i)))))))

(element-layer  (list  '(1 0 0 1 1 0 0 1 0 0 0 0)
                       '(0 2 3 0 4 5 0 6 0 7 8 0)
                       '(11 12 13 14 15 16 17))
                :rnd nil)

 => (1 11 2 1 1 3 12 1 4 5 13 6)

;;; hierarchic: every 0's will be replaced by the values from the next/sub-list...


Share this post

Link to post
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.

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.

Sign in to follow this  

  • Similar Topics

    • By InLight-Tone
      Just bought into OM, excellent software love it.
      If you could be so kind, what is the key sequence to call up the search function? That last key symbol is a mystery to me.
    • By Nikos
      I've noticed that, for example (rnd-round  1 15) returns floating point number instead of an integer. Could you please help?
      Thank you
    • By PatrickMimran
      I would like to know what the more efficient way , when creating a lot of  custom function to be included in the Extension folder:
      to group all the function in the same file
      or to distribute them over several files .  Or one function by file or it doesn't matter 
      Thank you   Patrick
  • Create New...