Skip to content

Commit d8ce05d

Browse files
committed
cleanup
1 parent ec38388 commit d8ce05d

13 files changed

+26
-125
lines changed

aplesque/aplesque.lisp

+1-13
Original file line numberDiff line numberDiff line change
@@ -1736,20 +1736,8 @@
17361736
;; containing output array is small
17371737
(symbol-macrolet ((output-element (row-major-aref output o)))
17381738
(dotimes (i (size (row-major-aref output o)))
1739-
;; (let ((iindex 0) (remaining o))
1740-
;; (loop :for ofactor :across output-factors :for ix :from 0
1741-
;; :do (multiple-value-bind (index remainder) (floor remaining ofactor)
1742-
;; (if (= ix axis)
1743-
;; (incf iindex (* i (aref input-factors axis))))
1744-
;; (incf iindex (* index (aref input-factors (+ ix (if (< ix axis) 0 1)))))
1745-
;; (setq remaining remainder)))
1746-
;; (if (= axis (rank output)) (incf iindex i))
1747-
;; (setf (row-major-aref output-element i)
1748-
;; (row-major-aref input iindex)))
17491739
(setf (row-major-aref output-element i)
1750-
(row-major-aref input (funcall indexer o i)))
1751-
1752-
)))
1740+
(row-major-aref input (funcall indexer o i))))))
17531741
output))))
17541742

17551743
(defun ravel (count-from input &optional axes)

functions.lisp

-3
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@
431431
(defun assign-by-selection (function value omega &key index-origin)
432432
"Assign to elements of an array selected by a function. Used to implement (3↑x)←5 etc."
433433
(multiple-value-bind (base-object ivec) (invert-assigned-varray (funcall function omega))
434-
;; (print (list :bb (setf rri base-object) ivec))
435434
(typecase base-object
436435
(varray::vader-select
437436
(setf (varray::vasel-assign base-object) value)
@@ -608,8 +607,6 @@
608607
(omrank (aref rank 0))
609608
(fn-meta (funcall function :get-metadata nil))
610609
(operand-lex-ref (getf fn-meta :lexical-reference)))
611-
;; (princ (list :ar rank (shape-of omega) (shape-of alpha) (getf fn-meta :lexical-reference) omega))
612-
;; (princ #\Newline)
613610

614611
(when (or (not (and (integerp ocrank) (or (zerop ocrank) (plusp ocrank))))
615612
(not (and (integerp acrank) (or (zerop acrank) (plusp acrank))))

grammar.lisp

-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@
148148
"Process a function token."
149149
(let* ((current-path (or (getf (rest (getf (getf properties :special) :closure-meta)) :ns-point)
150150
(symbol-value (intern "*NS-POINT*" space)))))
151-
;; (print (list :it this-item))
152151
(if (listp this-item)
153152
;; process a function specification starting with :fn
154153
(if (eq :fn (first this-item))

libraries/dfns/array/array.apl

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ acc ← { ⊃⍺⍺{(⊂⍺ ⍺⍺⊃⍬⍴⍵),⍵}/1↓{⍵,⊂⍬⍴⍵}¯1
3333

3434
From http://dfns.dyalog.com/c_disp.htm
3535

36-
disp { ⎕IO0 Boxed sketch of nested array.
37-
dec ctd2 1:decorated, 1:centred.
36+
disp { ⎕IO0 Boxed sketch of nested array.
37+
dec ctd2 1:decorated, 1:centred.
3838

3939
box{ Recursive boxing of nested array.
4040
isor :⎕FMT ⎕or: '∇name'.
@@ -146,7 +146,7 @@ display ← { ⎕IO←0 ⍝ Boxed display of array.
146146
top'─⊖→'[¯1],hrz upper border with axis
147147
bot(),hrz lower border with type
148148
rgt'┐│',vrt,'' right side with corners
149-
lax'│⌽↓'[¯11],¨vrt ⍝ left side(s) with axes,
149+
lax'│⌽↓'[¯11],¨vrt left side(s) with axes,
150150
lft'',(lax),'' ... and corners
151151
lft,(topbot),rgt fully boxed array
152152
}
@@ -159,7 +159,7 @@ display ← { ⎕IO←0 ⍝ Boxed display of array.
159159
type{{(1=)'+'},char¨} simple array type
160160
line{(49=⎕DT 1)' -'} underline for atom
161161

162-
{ ⎕IO0 recursive boxing of arrays:
162+
{ ⎕IO0 recursive boxing of arrays:
163163
0=:' '(open ⎕FMT )line simple scalar
164164
1 ()():'' 0 0 box ⎕FMT object rep: ⎕OR
165165
1=:(deco )box open ⎕FMT open simple array

libraries/dfns/graph/graph.apl

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ dsp pmat ← 'ARRAY-LIB-SPACE' ⎕XWF 'dsp' 'pmat'
1111
From http://dfns.dyalog.com/c_assign.htm
1212

1313
assign { Hungarian method cost assignment.
14-
1514
step0{step1(\)} 0: at least as many rows as cols.
1615

1716
step1{step2()-/} 1: reduce rows by minimum value.

libraries/dfns/numeric/demo.lisp

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@
125125
" ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ "
126126
" ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ "
127127
" ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ "))
128-
;; (is "{∧/⍵∧.=⍵∘.{+/⍺ nicediv ⍵}⍵}⍳50" 1) ;; TODO: why is this so slow when lazified?
128+
(is "{∧/⍵∧.=⍵∘.{+/⍺ nicediv ⍵}⍵} ⍳50" 1)
129129
(is "osc¨⍳30" #(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1))
130130
(is "0 5 10 15 range ¯2+⍳18" #(0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4))
131131
(is "¯1 0 1 range 1○⍳40"
132132
#(2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 1 2 2 2 1 1 1 2 2 2 1 1 1 2 2 2))
133-
(is "(5 7 to 20)range 2 3 4⍴1 to 24"
133+
(is "(5 7 to 20) range 2 3 4⍴1 to 24"
134134
#3A(((0 0 0 0) (1 1 2 2) (3 3 4 4)) ((5 5 6 6) (7 7 8 8) (8 8 8 8))))
135135
(is "rational 0.75" #(3.0d0 4.0d0))
136136
(is "rational (+∘÷)/¨1<⍳¨⍳10" #2A((0 1 1 2 3 5 8 13 21 34) (1 1 2 3 5 8 13 21 34 55)))

libraries/dfns/numeric/numeric.apl

+3-6
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ rational ← { ⍝ Rational approximation to rea
184184
From http://dfns.dyalog.com/c_roman.htm
185185

186186
roman { Roman numeral arithmetic.
187-
188187
num{⎕IO0 {+.××0.5+×-1,0}(,1 5.×10*4)[7|'IVXLCDMivxlcdm']}
189188
fmt{⎕IO0 ~' ',1 0 0(' '3 4'MCXI DLV ')[(0 4 2 20 16 20 22 24 32 36 38 39 28)[;410];]}
190189

@@ -324,8 +323,7 @@ kcell ← { ⍝ Relationship between point an
324323

325324
From http://dfns.dyalog.com/c_kball.htm
326325

327-
kball { Relationship between point and k-ball.
328-
1
326+
kball { 1 Relationship between point and k-ball.
329327
r p1/ Default is ball w/radius 1 at origin.
330328
c(p)1 Remaining coordinates are center.
331329
×-/(p-[⎕IO]c)r+.*¨2 Perform signum difference.
@@ -429,7 +427,6 @@ roots ← { ⍝ Roots of quadratic.
429427
From http://dfns.dyalog.com/c_polar.htm
430428

431429
polar { Polar from/to cartesian coordinates.
432-
433430
pol_car{ polar from cartesian (default).
434431
radius{(+*2)*0.5} radius (pythagorus).
435432

@@ -466,8 +463,7 @@ poly ← { 2 1∘.○(○2÷⍵)×(⍳⍵)-⍳1 }
466463

467464
From http://dfns.dyalog.com/c_xtimes.htm
468465

469-
xtimes { ⎕IO0 Fast multi-digit product using FFT.
470-
m0
466+
xtimes { ⎕IO0 m0 Fast multi-digit product using FFT.
471467
xroots {×\1,1(÷2)¯1*2÷}
472468
cube {22}
473469
extend {(2*2¯1+()+)¨ }
@@ -476,6 +472,7 @@ xtimes ← { ⎕IO←0 ⍝ Fast multi-digit product
476472
iFFT {()÷,(cube+xroots)floop cube }
477473
rconvolve {(¯1+()+)iFFT×/FFT¨ extend }
478474
carry {1+1 00,0 10}
475+
479476
(+/\0=t)tcarry0,0.5+9 rconvolve
480477
}
481478

novelties.lisp

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ This will invoke a progress bar with different demarcations (at each third rathe
8383
(defun april-print-progress-bar (count &key (increments (april "1 2 3÷4"))
8484
(width 64) (glyphs "⋄⌺∘○ ╷╓╖─┼╟╢"))
8585
"Print a progress bar that will grow toward completion as a process advances."
86-
(let* ((total 0) (printed 0) (interval-index 0) (current-interval 0)
87-
(breadth (* width count))
88-
(marked-intervals (april-c (with (:state :in ((glyphs glyphs))))
89-
"{
86+
(let ((total 0) (printed 0) (interval-index 0) (current-interval 0)
87+
(breadth (* width count))
88+
(marked-intervals (april-c (with (:state :in ((glyphs glyphs))))
89+
"{
9090
⎕IO ← 0
9191
mrk ← 1+⍸ind ← ¯1⌽(⊢<1∘⌽)(⍵×int ← ⍺[⍋⍺])⍸⍳⍵-2
9292
⍝ locations of marked intervals, with width minus 2 for enclosing chars
@@ -98,7 +98,7 @@ This will invoke a progress bar with different demarcations (at each third rathe
9898
9999
mrk ⍝ return indices of marked increments
100100
}"
101-
width increments)))
101+
width increments)))
102102
;; the returned advance function should be called upon each iteration of the process
103103
(lambda ()
104104
(when (< total breadth)

spec.lisp

+5-4
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,9 @@
953953
(meta (primary :axes axes :implicit-args (index-origin))
954954
(monadic :inverse #'identity)
955955
(dyadic :on-axis :last))
956-
(tests (is "⊆ ⍳3" #0A#(1 2 3))
957-
(is "⊆⊂⍳3" #0A#(1 2 3))
956+
(tests (is " ⊆ ⍳3" #0A#(1 2 3))
957+
(is " ⊆⊂⍳3" #0A#(1 2 3))
958+
(is "⊃⊆⊂⍳3" #(1 2 3))
958959
(is "⊆1 2 (1 2 3)" #(1 2 #(1 2 3)))
959960
(is "⊆ 'hello'" #0A"hello")
960961
(is "⊆⊂'hello'" #0A"hello")
@@ -2081,8 +2082,8 @@
20812082
(for "Aliasing of [⌸ key] operator."
20822083
"{k←⌸ ⋄ {⍴⍵}k ⍵} 'Apple' 'Orange' 'Apple' 'Pear' 'Orange' 'Peach'" #2A((2) (2) (1) (1)))
20832084
(for "Aliasing of [. inner product] operator." "{ip←. ⋄ ⍵ +ip× 4 5 6} 1 2 3" 32)
2084-
(for "Aliasing of [∘ compose] operator." "{c←∘ ⋄ ⍴ c ⍴ ⍵} ⍳9" #*1)
2085-
(for "Aliasing of [⍛ reverse compose] operator." "{c←⍛ ⋄ ⍵ - c - ⍵} 1" -2)
2085+
(for "Aliasing of [∘ beside] operator." "{c←∘ ⋄ ⍴ c ⍴ ⍵} ⍳9" #*1)
2086+
(for "Aliasing of [⍛ before] operator." "{c←⍛ ⋄ ⍵ - c - ⍵} 1" -2)
20862087
(for "Aliasing of [⍤ rank] operator." "{r←⍤ ⋄ ⍵+r 1⊢3 3⍴⍳9} ⍳3" #2A((2 4 6) (5 7 9) (8 10 12)))
20872088
(for "Aliasing of [⍥ over] operator." "8 10 12 {o←⍥ ⋄ (⍺×⍵)÷o(+/)⍺} 16 32 64" 608/15)
20882089
(for "Aliasing of [⍣ power] operator." "{p←⍣ ⋄ ⍳ p ¯1⊢⍵} ⍳9" 9)

utilities.lisp

+1-58
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,6 @@
393393

394394
(defun reg-symfn-call (function space meta-form)
395395
"Add a reference to a call to a symbolic function to a closure metadata object."
396-
;; (print (list :ff function meta-form))
397-
;; (print :ff)
398396
(when (and meta-form function (listp function))
399397
(if (eql 'sub-lex (first function))
400398
(reg-symfn-call (second function) space meta-form)
@@ -1007,33 +1005,6 @@
10071005
(setf (symbol-function 'parse-apl-number-string) #'nparser)
10081006
#'nparser)))
10091007

1010-
;; (defun parse-apl-number-string (number-string &optional component-of)
1011-
;; "Parse an APL numeric string into a Lisp value, handling high minus signs, J-notation for complex numbers and R-notation for rational numbers."
1012-
;; (ignore-errors ;; if number parsing fails, just return nil
1013-
;; (let ((nstring (string-upcase (regex-replace-all "[_]" number-string ""))))
1014-
;; (if (and (not (eql 'complex component-of))
1015-
;; (position #\J nstring :test #'char=))
1016-
;; (let ((halves (cl-ppcre:split #\J nstring)))
1017-
;; (when (and (= 2 (length halves))
1018-
;; (< 0 (length (first halves)))
1019-
;; (< 0 (length (second halves))))
1020-
;; (complex (parse-apl-number-string (first halves) 'complex)
1021-
;; (parse-apl-number-string (second halves) 'complex))))
1022-
;; (if (position #\E nstring :test #'char=)
1023-
;; (let ((exp-float (parse-number:parse-number (regex-replace-all "[¯]" nstring "-")
1024-
;; :float-format 'double-float)))
1025-
;; (if (< double-float-epsilon (nth-value 1 (floor exp-float)))
1026-
;; exp-float (let ((halves (mapcar #'parse-apl-number-string (cl-ppcre:split #\E nstring))))
1027-
;; (floor (* (first halves) (expt 10 (second halves)))))))
1028-
;; (if (and (not (eql 'rational component-of))
1029-
;; (position #\R nstring :test #'char=))
1030-
;; (let ((halves (cl-ppcre:split #\R nstring)))
1031-
;; (/ (parse-apl-number-string (first halves) 'rational)
1032-
;; (parse-apl-number-string (second halves) 'rational)))
1033-
;; ;; the macron character is converted to the minus sign
1034-
;; (parse-number:parse-number (regex-replace-all "[¯]" nstring "-")
1035-
;; :float-format 'double-float)))))))
1036-
10371008
(defun print-apl-number-string (number &optional segments precision decimals realpart-multisegment)
10381009
"Format a number as appropriate for APL, using high minus signs and J-notation for complex numbers, optionally at a given precision and post-decimal length for floats."
10391010
(cond ((complexp number)
@@ -1198,15 +1169,14 @@
11981169
:functions-scalar-monadic))))
11991170
(arguments (loop :for arg :in arguments :collect (if (or (not (symbolp arg)))
12001171
arg `(vrender ,arg :may-be-deferred t)))))
1201-
;; (print (list :aa arguments))
12021172
(or (when (and (listp function)
12031173
(eql 'function (first function))
12041174
(eql 'change-namespace (second function)))
12051175
`(identity t))
12061176
(progn (when (and (listp function) (eql 'nspath (first function)))
12071177
(let* ((ns-sym (intern "*NS-POINT*" (package-name (symbol-package (second function)))))
12081178
(namespace (if (boundp ns-sym) (symbol-value ns-sym))))
1209-
(when namespace (setq function
1179+
(when namespace (setf function
12101180
(cons 'nspath (append (if (listp namespace) namespace
12111181
(list namespace))
12121182
(list (intern (string (second function))
@@ -1216,17 +1186,6 @@
12161186
(apply ,@(when is-scalar (list '#'apply-scalar))
12171187
,function ,arg-list))))))
12181188

1219-
#|
1220-
This is a minimalistic implementation of (a-call) that doesn't perform any function composition.
1221-
It remains here as a standard against which to compare methods for composing APL functions.
1222-
1223-
(defmacro a-call (function &rest arguments)
1224-
`(,(if (and (listp function)
1225-
(eql 'scalar-function (first function)))
1226-
'apply-scalar 'funcall)
1227-
,function ,@arguments))
1228-
|#
1229-
12301189
(defmacro ac-wrap (type form)
12311190
"Wrap a function form in a function that calls it via (a-call). Used for specification of inverse scalar functions."
12321191
(list (if (eq :m type) 'λω 'λωα)
@@ -1342,9 +1301,6 @@ It remains here as a standard against which to compare methods for composing APL
13421301
(= 1 (size-of ,condition)))
13431302
(disclose-atom (vrender ,condition))
13441303
(error "Predicates within an [$ if] statement must be unitary or scalar."))))
1345-
;; (if (not (is-unitary ,condition))
1346-
;; (error "Predicates within an [$ if] statement must be unitary or scalar.")
1347-
;; (print (list :co ,condition ,output))
13481304
(if (zerop ,output)
13491305
,(if (third clauses)
13501306
(if (fourth clauses)
@@ -2030,7 +1986,6 @@ It remains here as a standard against which to compare methods for composing APL
20301986
this-form))
20311987
((guard symbol (member symbol '(⍺ ⍵ ⍶ ⍹ ⍺⍺ ⍵⍵)))
20321988
;; handle argument symbols, adding them to the closure-meta list
2033-
;; (print (list :sy symbol closure-meta))
20341989
(unless closure-meta
20351990
;; create the meta form if not present, needed for cases like 2{⍶⋄⍹}3⊢10
20361991
(setf closure-meta (list :arg-syms nil)))
@@ -2116,17 +2071,6 @@ It remains here as a standard against which to compare methods for composing APL
21162071
:inverse-right :inverse))
21172072
,arg1 ,(funcall to-wrap form))))))))))))))
21182073

2119-
;; (defmacro plain-ref (function &optional axes)
2120-
;; "Wrap a lexical function; this is needed to implement some meta-functionality."
2121-
;; ;; TODO: can the functionality here and in amb-ref be factored out and merged?
2122-
;; (let ((this-fn (gensym)) (args (gensym)) (iargs (gensym)))
2123-
;; `(labels ((,this-fn (&rest ,args)
2124-
;; ,@(when axes `((when (eq :assign-axes (first ,args))
2125-
;; (setq ,axes (second ,args)
2126-
;; ,args (cddr ,args)))))
2127-
;; (apply ,function ,args)))
2128-
;; #',this-fn)))
2129-
21302074
(defmacro plain-ref (function &optional axes)
21312075
"Wrap a lexical function; this is needed to implement some meta-functionality."
21322076
;; TODO: can the functionality here and in amb-ref be factored out and merged?
@@ -2284,7 +2228,6 @@ It remains here as a standard against which to compare methods for composing APL
22842228
(push `(symbol-function ',aliased) assignment-forms)
22852229
(case spec-type (functions (incf afn-count))
22862230
(operators (incf aop-count)))
2287-
;; (print (list :ach achar lexicons))
22882231
;; assign the alias to lexicons according to the lexicon
22892232
;; membership (as specified in this form or already
22902233
;; present in the current lexicon) of the character

0 commit comments

Comments
 (0)