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.

merge-rotated-sublists function

Featured Replies

Hello, Opusmoders

I did (with a little help of Notebooklm) this cool function whose function is to concatenate 2 diferent lists with sublists, merging the first sublist of the list A with the first sublist of list B, with the options
1) to choose how many elements of each list to use; and

2) the possibility of not only mix different numbers of elements in each list but also the possibility to select the starting element of the list to pick elements.

3) The function also consider each list as a rotating element: for example, if 5 elements are required from the list (1 2 3), starting in the first element, the result will be (1 2 3 1 2), if the start is on the second element, the result will be (2 3 1 2 3) and so on.

This is useful for me. Hope you like it.

Best,

Julio

(defun get-rotated-elements (lst start count)

"Extracts COUNT elements from LST starting at index START, wrapping around if needed."

(let ((len (length lst)))

(loop for i from 0 below count

collect (nth (mod (+ start i) len) lst))))

(defun merge-rotated-sublists (list-a list-b counts-a counts-b starts-a starts-b)

"Merges sublists from A and B based on specific counts and starting positions with rotation."

(mapcar #'(lambda (sub-a sub-b n m s-a s-b)

(append (get-rotated-elements sub-a s-a n)

(get-rotated-elements sub-b s-b m)))

list-a list-b counts-a counts-b starts-a starts-b))

Example of Usage

(setf list-a '((1 2 3 4) (a b c) (q w e r t)))

(setf list-b '((4 5 6 7) (d e f) (a s d f g)))

(merge-rotated-sublists list-a list-b '(2 1 5) '(1 5 3) '(0 2 2) '(0 0 1))

;; Result: ((1 2 4) (c d e f d e) (e r t q w s d f))

(merge-rotated-sublists list-a list-b '(2 7 1) '(4 3 7) '(0 0 0) '(1 1 0))

;((1 2 5 6 7 4) (a b c a b c a e f d) (q a s d f g a 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

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.