Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Common Lisp: 262 significant characters</h2> <blockquote> <p>(defun [(n)(format t"[~a]"n))(defun p(c m &amp;key(s 5)(p 2))(let((l(max(min(- c p)(- m s -1))1))(r(min(max(+ c(- p)s -1)s)m)))(when(> l 1)([ 1))(when(> l 2)(princ"..."))(loop for n from l to r do([ (if(= n c)#\x n)))(when(&lt; r(1- m))(princ"..."))(when(&lt; r m)([ m))))</p> </blockquote> <p>Uncompressed:</p> <pre><code>(defun print[] (n) (format t "[~a]" n)) (defun page-bar (current max &amp;key (subset-size 5) (current-position 2)) (let ((left (max (min (- current current-position) (- max subset-size -1)) 1)) (right (min (max (+ current (- current-position) subset-size -1) subset-size) max))) (when (&gt; left 1) (print[] 1)) (when (&gt; left 2) (princ "...")) (loop for p from left upto right do (print[] (if (= p current) #\x p))) (when (&lt; right (1- max)) (princ "...")) (when (&lt; right max) (print[] max)))) </code></pre> <p>Testing:</p> <pre><code>CL-USER&gt; (mapc (lambda (n) (p n 7) (format t "~%")) '(1 2 3 4 5 6 7)) [x][2][3][4][5]...[7] [1][x][3][4][5]...[7] [1][2][x][4][5]...[7] [1][2][3][x][5][6][7] [1]...[3][4][x][6][7] [1]...[3][4][5][x][7] [1]...[3][4][5][6][x] (1 2 3 4 5 6 7) CL-USER&gt; (p 1 1) [x] NIL CL-USER&gt; (p 1 2) [x][2] NIL CL-USER&gt; (p 0 0) NIL CL-USER&gt; (p 0 1) [1] NIL CL-USER&gt; (p 0 30) [1][2][3][4][5]...[30] NIL CL-USER&gt; (p 31 30) [1]...[26][27][28][29][30] NIL </code></pre> <p>The subset size and the position of the current page in that subset can be given in optional parameters (<code>:current-position</code> is zero-based within the subset, naturally):</p> <pre><code>CL-USER&gt; (page-bar 8 15 :subset-size 6 :current-position 5) [1]...[3][4][5][6][7][x]...[15] NIL </code></pre> <p><em>EDIT:</em> The call in the compressed version would be:</p> <pre><code>CL-USER&gt; (p 8 15 :s 6 :p 5) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload