这个 emacs-lisp 代码有什么作用?
What does this emacs-lisp code do?
我对函数 "do-something" 的作用感到很困惑。也许我可以换个名字。
(defun do-something (m &optional n)
(let* ((count (if (null n) 20 n))
(bound (* count m)))
(loop for i from 0 below m
do (princ "[ ")
(loop for j from (+ (- bound) i) to (+ bound i) by m
do (princ j)
(princ " "))
(princ "]\n"))))
您可以通过剪切'n'粘贴到缓冲区和 运行 C-x C-e (eval-last-sexp)
在 emacs 上试用
(do-something 10 10)
[ -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 ]
[ -99 -89 -79 -69 -59 -49 -39 -29 -19 -9 1 11 21 31 41 51 61 71 81 91 101 ]
[ -98 -88 -78 -68 -58 -48 -38 -28 -18 -8 2 12 22 32 42 52 62 72 82 92 102 ]
[ -97 -87 -77 -67 -57 -47 -37 -27 -17 -7 3 13 23 33 43 53 63 73 83 93 103 ]
[ -96 -86 -76 -66 -56 -46 -36 -26 -16 -6 4 14 24 34 44 54 64 74 84 94 104 ]
[ -95 -85 -75 -65 -55 -45 -35 -25 -15 -5 5 15 25 35 45 55 65 75 85 95 105 ]
[ -94 -84 -74 -64 -54 -44 -34 -24 -14 -4 6 16 26 36 46 56 66 76 86 96 106 ]
[ -93 -83 -73 -63 -53 -43 -33 -23 -13 -3 7 17 27 37 47 57 67 77 87 97 107 ]
[ -92 -82 -72 -62 -52 -42 -32 -22 -12 -2 8 18 28 38 48 58 68 78 88 98 108 ]
[ -91 -81 -71 -61 -51 -41 -31 -21 -11 -1 9 19 29 39 49 59 69 79 89 99 109 ]
如您所见,它以某种形式打印二维数组。
我对函数 "do-something" 的作用感到很困惑。也许我可以换个名字。
(defun do-something (m &optional n)
(let* ((count (if (null n) 20 n))
(bound (* count m)))
(loop for i from 0 below m
do (princ "[ ")
(loop for j from (+ (- bound) i) to (+ bound i) by m
do (princ j)
(princ " "))
(princ "]\n"))))
您可以通过剪切'n'粘贴到缓冲区和 运行 C-x C-e (eval-last-sexp)
在 emacs 上试用(do-something 10 10)
[ -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 ]
[ -99 -89 -79 -69 -59 -49 -39 -29 -19 -9 1 11 21 31 41 51 61 71 81 91 101 ]
[ -98 -88 -78 -68 -58 -48 -38 -28 -18 -8 2 12 22 32 42 52 62 72 82 92 102 ]
[ -97 -87 -77 -67 -57 -47 -37 -27 -17 -7 3 13 23 33 43 53 63 73 83 93 103 ]
[ -96 -86 -76 -66 -56 -46 -36 -26 -16 -6 4 14 24 34 44 54 64 74 84 94 104 ]
[ -95 -85 -75 -65 -55 -45 -35 -25 -15 -5 5 15 25 35 45 55 65 75 85 95 105 ]
[ -94 -84 -74 -64 -54 -44 -34 -24 -14 -4 6 16 26 36 46 56 66 76 86 96 106 ]
[ -93 -83 -73 -63 -53 -43 -33 -23 -13 -3 7 17 27 37 47 57 67 77 87 97 107 ]
[ -92 -82 -72 -62 -52 -42 -32 -22 -12 -2 8 18 28 38 48 58 68 78 88 98 108 ]
[ -91 -81 -71 -61 -51 -41 -31 -21 -11 -1 9 19 29 39 49 59 69 79 89 99 109 ]
如您所见,它以某种形式打印二维数组。