You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.org
+94Lines changed: 94 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2652,6 +2652,100 @@ Describe things like exporting an Org readme to an Info manual, e.g. like Magit,
2652
2652
2653
2653
[2017-07-29 Sat 00:33] Not only should you test installing and using your package in the sandbox, but you should /also/ test then exiting the sandbox Emacs, running it again with the package already installed, and loading it. This is because, when the sandbox installs the package, the byte-compilation seems to load some things that won't be loaded the same way when only loading the byte-compiled file (especially if you have any ~eval-when-compile~ lines, or unusual macros or things that modify the environment when loaded).
2654
2654
2655
+
** TODO Sequence shuffling examples and benchmarks
2656
+
*** Benchmarking sequence shuffling
2657
+
2658
+
See https://github.com/melpa/melpa/pull/6191#issuecomment-498101336
2659
+
2660
+
#+BEGIN_SRC elisp
2661
+
(defun key-quiz--shuffle-list (list)
2662
+
"Shuffles LIST randomly, modying it in-place."
2663
+
(dolist (i (reverse (number-sequence 1 (1- (length list)))))
2664
+
(let ((j (random (1+ i)))
2665
+
(tmp (elt list i)))
2666
+
(setf (elt list i) (elt list j))
2667
+
(setf (elt list j) tmp)))
2668
+
list)
2669
+
2670
+
(defun key-quiz--shuffle-list-nreverse (list)
2671
+
"Shuffles LIST randomly, modying it in-place."
2672
+
(dolist (i (nreverse (number-sequence 1 (1- (length list)))))
2673
+
(let ((j (random (1+ i)))
2674
+
(tmp (elt list i)))
2675
+
(setf (elt list i) (elt list j))
2676
+
(setf (elt list j) tmp)))
2677
+
list)
2678
+
2679
+
(defun elfeed--shuffle (seq)
2680
+
"Destructively shuffle SEQ."
2681
+
(let ((n (length seq)))
2682
+
(prog1 seq ; don't use dotimes result (bug#16206)
2683
+
(dotimes (i n)
2684
+
(cl-rotatef (elt seq i) (elt seq (+ i (random (- n i)))))))))
2685
+
2686
+
(defun faster-seq-sort-by (function pred sequence)
2687
+
"Sort SEQUENCE using PRED as a comparison function.
2688
+
Elements of SEQUENCE are transformed by FUNCTION before being
2689
+
sorted. FUNCTION must be a function of one argument."
2690
+
;; This version is modified to avoid calling "random" twice every time the predicate is called.
2691
+
(seq-map 'cdr
2692
+
(sort (seq-map (lambda (x) (cons (funcall function x) x)) sequence)
0 commit comments