RaZgRiZ

recyclelist thingy.

Oct 18th, 2013
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. // Command which allows given items from given list to be recycled based
  2. // on basic index reordering, usage: /recyclelist $list [indexes] "step"
  3. //   example with a step of 2 and 3 respectively with a list of "1 3 5 7 9"
  4. //   and indexes the list itself, will result: "5 7 9 1 3" / "7 9 1 3 5"
  5. recyclelist = [
  6.     local l n tmp
  7.     l = (- (listlen $arg2) (= $arg2 -1)) ; n = (- $l $arg3) ; tmp = $arg1
  8. //  do (format "n = (concat (sublist %1 %2 %3) (sublist %1 0 %2))" (    //
  9. //      ? (= $arg2 -1) (loopconcat i $l [result $i]) $arg2              // could work somehow?
  10. //  ) $n $arg3)                                                         //
  11.     n = (concat (sublist $arg2 $n $arg3) (sublist $arg2 0 $n))
  12.     loop i $l [
  13.         tmp = (listsplice $tmp [[@@(at $arg1 (at $arg2 $i))]] (at $n $i) 1)
  14.     ]
  15.     result $tmp
  16. ]
Advertisement
Add Comment
Please, Sign In to add comment