---------------------------------------------------------
D-functions and operators loosely grouped into categories
---------------------------------------------------------
Click function name in list below to see notes, and within the note:
┌───────────── click here to see function coding
┌────────────────│─────────── ···
│ rslt ← larg ##.foo rarg ⍝ description ···
│
│ ··· related function →goo← is a ···
│ │
│ See also: hoo koo ··· │
└───────────│───────────│─── ···
│ │
│ │
└───────────┴─── click here to see notes for related function.
The above "header line" in the notes gives a _hint_ of the syntax of the funct-
ion or operator it describes. The informal syntax is modelled on the header line
of a traditional APL function in that it names its arguments and results and an
_optional_ left argument is embraced by curly braces. Default values for option-
al left arguments are indicated by assignment '←'. Here is an example:
fmat ← {gap←1 {max←⎕pw}} ##.cols items ⍝ Multi-column display.
└───────┬───────┘
│
└──────── [cols] takes an optional 1 or 2 item left argument,
with default values 1 and ⎕pw.
Note that some functions appear in more than one category.
· Structures.
· ·
· · Arrays.
· · · alists ⍝ Association lists.
· · · acc ⍝ Accumulating reduction.
· · · box ⍝ Box the simple text array ⍵.
· · · chksum ⍝ Simple ⍺-digit checksum.
· · · cmat ⍝ ⍺-combination matrix of ⍳⍵.
· · · cols ⍝ Multi-column display.
· · · disp ⍝ Boxed sketch of nested array.
· · · display ⍝ Boxed display of array.
· · · displays ⍝ Boxed display of array with axis lengths.
· · · displayr ⍝ Boxed display of array with sub-array depths.
· · · enlist ⍝ List ⍺-leaves of nested array.
· · · enss ⍝ Emulate (∊⍺)←⍵.
· · · find ⍝ Lines containing string(s) ⍵.
· · · from ⍝ Select (1↓⍴⍵)-cells from array.
· · · foldl ⍝ Fold (reduce) from the left.
· · · iotag ⍝ Generalized iota.
· · · key ⍝ Key operator.
· · · lex ⍝ Lexicographical comparison of arrays ⍺ and ⍵.
· · · list ⍝ List from vector ⍵.
· · · ltrav ⍝ List traversal.
· · · merge ⍝ Suggestion for a merge operator.
· · · mns ⍝ Make NS from association list ⍵.
· · · nlines ⍝ Number of display lines for simple array.
· · · pack ⍝ Saves WS by sharing identical sub-arrays.
· · · perv ⍝ Scalar pervasion, apply function between scalars.
· · · pmat ⍝ Permutation matrix of ⍳⍵.
· · · pred ⍝ Partitioned reduction.
· · · rank ⍝ Apply function to/between sub-arrays.
· · · rows ⍝ Operand function applied to argument rows.
· · · sam ⍝ Select and modify.
· · · saw ⍝ Operand function applied Simple-Array-Wise.
· · · scan ⍝ Variations on primitive scan.
· · · select ⍝ ⍺-selection of items from vector ⍵.
· · · subvec ⍝ Is ⍺ a subvector of ⍵?
· · · squad ⍝ IBM APL2 Indexing function.
· · · subs ⍝ Vector substitution.
· · · type ⍝ Array of type ⍺.
·
· · Trees
· · · BST ⍝ Binary Search Trees.
· · · · avl ⍝ Adelson-Velskii, Landis (AVL) trees.
· · · · sbst ⍝ Simple binary search trees.
· · · · redblack ⍝ Red-black trees.
· · · · splay ⍝ Splay trees.
· · · ddft ⍝ Display derived function tree.
· · · tfmt ⍝ Char matrix from tree(s).
· · · tnest ⍝ Array from TreeView style tree.
· · · tview ⍝ TreeView style tree from nested array.
· · · tree ⍝ Display of namespace tree.
·
· · Graphs
· · · assign ⍝ Hungarian method cost assignment.
· · · insnode ⍝ Insert vertex ⍵ in graph ⍺.
· · · remnode ⍝ Remove vertex ⍵ from graph ⍺.
· · · inslink ⍝ Insert edge ⍵ in graph ⍺.
· · · remlink ⍝ Remove edge ⍵ from graph ⍺.
· · · popnode ⍝ Pop vertex ⍵ to head of graph ⍺.
· · · search ⍝ Breadth-first search of graph ⍺.
· · · path ⍝ Shortest path from/to ⍵ in graph ⍺.
· · · span ⍝ Breadth-first spanning tree for graph ⍺.
· · · dfspan ⍝ Depth-first spanning tree for graph ⍺.
· · · stdists ⍝ Spanning tree path lengths.
· · · stpath ⍝ Path through spanning tree ⍺ to vertex ⍵.
· · · stpaths ⍝ Spanning tree paths.
·
· · wGraphs ⍝ Weighted graphs.
· · · wcost ⍝ Cost vector for path ⍵ through _weighted_ graph ⍺.
· · · wpath ⍝ Quickest path from/to ⍵ in _weighted_ graph ⍺.
· · · wspan ⍝ Spanning tree for _weighted_ graph ⍺ from ⍵.
· · · wmst ⍝ Minimum Spanning Tree for _weighted_ graph ⍺.
·
· · Words.
· · · ssword ⍝ Approx alternative to xutils' ss.
· · · words ⍝ Source vector split into words.
· · · tokens ⍝ Lex of APL source line.
· · · von ⍝ Capitalise first letters of names.
·
· · Strings.
· · · find ⍝ Search for string ⍵ in vars, fns and ops.
· · · just ⍝ Justify text array.
· · · lcase ⍝ Lower-casification.
· · · ucase ⍝ Upper-casification.
· · · mtrim ⍝ Trim trailing blank columns from matrix.
· · · ss ⍝ Approx alternative to xutils' string replacement.
· · · ssmat ⍝ Matrix search/replace.
· · · ssword ⍝ Approx alternative to xutils' word replacement.
· · · subs ⍝ Vector substitution.
· · · subvec ⍝ Is ⍺ a subvector of ⍵?
· · · squeeze ⍝ Compress multiple blanks.
· · · timestamp ⍝ Time-stamped message.
· · · xtabs ⍝ Expand/compress HT chars.
· · · htx ⍝ Extract html segments.
·
· · Line_vectors
· · · htx ⍝ Extract html segments.
· · · ltov ⍝ Lines to nested vector.
· · · vtol ⍝ Nested vector to lines.
· · · wrap ⍝ Wrap word vector at ⍺ columns.
· · · unwrap ⍝ Replace [LF] with blanks.
· · · justify ⍝ Justify line-vector to ⍺ columns.
· · · squeeze ⍝ Compress multiple blanks.
· · · vtrim ⍝ Trim trailing blanks from line-vector.
· · · wrapnote ⍝ Wrap text paragraphs in note vector.
· · · xtabs ⍝ Expand/compress HT chars.
·
· · Blank_removal
· · · dlb ⍝ Drop Leading Blanks.
· · · dtb ⍝ Drop Trailing Blanks.
· · · deb ⍝ Drop Ending Blanks.
· · · dxb ⍝ Drop eXtraneous Blanks.
· · · dmb ⍝ Drop Multiple Blanks.
· · · dab ⍝ Drop All Blanks.
·
· · Data_compression
· · · packB ⍝ Pack a simple array.
· · · packD ⍝ Pack char array to boolean vector.
· · · packH ⍝ Huffman packing.
· · · packN ⍝ Zero packing.
· · · packQ ⍝ Assorted uniQues packer.
· · · packR ⍝ RLE packing.
· · · packS ⍝ Shannon-Fano packing.
· · · packT ⍝ Simple text vector packager.
· · · packU ⍝ Unique packer.
· · · packX ⍝ TeXt packer.
· · · packZ ⍝ Lempel-Ziv-Welch.
·
· · Power.operators
· · · cond ⍝ Conditional function application.
· · · do ⍝ Apply no-result function "en passant".
· · · else ⍝ Condition f else g ...
· · · for ⍝ Multiple selection of function list.
· · · inverse ⍝ General function inverse.
· · · invr ⍝ Approx inverse of real-valued function.
· · · invs ⍝ Symbolic inverse.
· · · limit ⍝ Function power limit (fixpoint).
· · · pow ⍝ Explicit function power.
· · · traj ⍝ Function limit "trajectory".
· · · while ⍝ Conditional function power.
· · · until ⍝ Conditional function power.
·
· · Function_arrays
· · · case ⍝ select statement.
· · · for ⍝ Multiple selection of function list.
· · · of ⍝ pick'th fn applied to arg.
· · · lof ⍝ List of functions.
· · · logic ⍝ logical function array.
· · · vof ⍝ Vector of functions.
· · · fnarray ⍝ Array of functions.
·
· · Syntax.operators
· · · and ⍝ Sequential test.
· · · cond ⍝ Conditional function application.
· · · do ⍝ Apply no-result function "en passant".
· · · fork ⍝ Function fork.
· · · or ⍝ Sequential test.
· · · rank ⍝ Apply function to/between sub-arrays.
·
· · Expressions.
· · · ddft ⍝ Display derived function tree.
· · · htx ⍝ Extract html segments.
· · · rmcm ⍝ Remove comment from line of APL.
· · · unify ⍝ Unification of expressions.
·
· Numbers.
· ·
· · Whole.numbers
· · · adic ⍝ Bijective base-⍺ numeration.
· · · big ⍝ Arithmetic on large integers.
· · · bsearch ⍝ Binary search: least n in range ⍵ such that ⍺⍺ n.
· · · bt ⍝ Balanced Ternary Arithmetic.
· · · cfract ⍝ Continued fraction approximation of real number.
· · · colsum ⍝ Sum of (default decimal) columns.
· · · dec ⍝ Decimal from hexadecimal.
· · · decf ⍝ Numbers from (big-endian) floating hex.
· · · efract ⍝ Egyptian fraction for ⍺÷⍵.
· · · esh ⍝ Shell for Eide-number sums.
· · · factorial ⍝ Tail-recursive factorial.
· · · fibonacci ⍝ Tail-recursive Fibonacci.
· · · factors ⍝ Prime factors of ⍵.
· · · gcd ⍝ Greatest common divisor.
· · · lcm ⍝ Least common multiple.
· · · hex ⍝ Hexadecimal from decimal.
· · · hexf ⍝ (big-endian) hex display of float array.
· · · int ⍝ Signed from unsigned integers.
· · · nats ⍝ Natural number arithmetic.
· · · nicediv ⍝ ⍵ similar integers with sum ⍺.
· · · osc ⍝ Oscillate - probably returns 1.
· · · pco ⍝ Prime numbers.
· · · range ⍝ Numeric range classification.
· · · rational ⍝ Rationals tolerably close to real ⍵.
· · · rats ⍝ Rational arithmetic.
· · · ratsum ⍝ ⍺⍺-rational sum of ⍺ and ⍵.
· · · stamps ⍝ Postage stamps to the value of ⍵.
· · · sieve ⍝ Sieve of Eratosthenes.
· · · to ⍝ Sequence ⍺ .. ⍵
· · · uns ⍝ Unsigned from signed integers.
· · Rational.numbers
· · · ary ⍝ ⍺-ary representation of rational ⍵.
· · · cfract ⍝ Continued fraction approximation of real number.
· · · efract ⍝ Egyptian fraction for ⍺÷⍵.
· · · esh ⍝ Shell for Eide-number sums.
· · · gcd ⍝ Greatest common divisor.
· · · lcm ⍝ Least common multiple.
· · · rational ⍝ Rationals tolerably close to real ⍵.
· · · rats ⍝ Rational arithmetic.
· · · ratsum ⍝ ⍺⍺-rational sum of ⍺ and ⍵.
·
· · Real.numbers
· · · abc ⍝ Arithmetic Boundary Checking.
· · · cfract ⍝ Continued fraction approximation of real number.
· · · det ⍝ Determinant of square numeric matrix.
· · · efract ⍝ Egyptian fraction for ⍺÷⍵.
· · · gauss_jordan ⍝ Gauss-Jordan elimination.
· · · invr ⍝ Approx inverse of real-valued function.
· · · kcell ⍝ Relationship between point and k-cell.
· · · kball ⍝ Relationship between point and k-ball.
· · · ksphere ⍝ Hypersphere surface and volume.
· · · mean ⍝ Arithmetic mean.
· · · phinary ⍝ Phinary rep of scalar number ⍵.
· · · root ⍝ ⍺'th root.
· · · roots ⍝ Real roots of quadratic.
·
· · Complex.numbers
· · · cx ⍝ Complex arithmetic.
· · · cxdraw ⍝ Complex function drawing.
· · · cxsh ⍝ Complex shell.
· · · polar ⍝ Polar from cartesian coordinates.
·
· · Dates
· · · cal ⍝ Calendar.
· · · days ⍝ Day number from ⎕TS format.
· · · date ⍝ ⎕TS format from day number.
· · · easter ⍝ Easter Day in year ⍵.
· · · timestamp ⍝ Time-stamped message.
·
· Workspace.administration
· ·
· · Workspaces
· · · dfnscode ⍝ Formatted dfns code.
· · · dfnsnotes ⍝ Formatted dfns notes.
· · · exit ⍝ Return to calling environment.
· · · fndiff ⍝ Defined function differences.
· · · index ⍝ ⍵-index of notes in space ⍺.
· · · refws ⍝ Ref to "saved" ws ⍵.
· · · test ⍝ Run test script: no news => good news.
· · · utf8 ⍝ ⎕AV ←→ UTF-8 translation.
· · · wsdiff ⍝ Workspace differences.
· · · wsmerge ⍝ {protected} merge from saved ws.
· · · xhtml ⍝ Export this WS to ⍵\*.htm.
· · · xws ⍝ Execute expr ⍺ in saved ws ⍵.
·
· · Namespaces
· · · index ⍝ ⍵-index of notes in space ⍺.
· · · mns ⍝ Make NS from association list ⍵.
· · · nspack ⍝ Share arrays across space tree.
· · · refs ⍝ Vector of sub-space references.
· · · refmatch ⍝ Space reference match.
· · · tree ⍝ Display of namespace tree.
· · · up ⍝ Ref to ⍵-parent of space ⍺.
· · · vwise ⍝ Variable-wise: apply ⍺⍺ to each var in space ⍵.
· · · xrefs ⍝ Extract refs vector from array ⍵.
·
· · Functions.and.operators
· · · ambiv ⍝ Ambivalize traditional functions: ⍵.
· · · attrib ⍝ Function/operator attributes.
· · · defn ⍝ D-fine function.
· · · dots ⍝ Show dfn with "white dots".
· · · find ⍝ Search for string ⍵ in vars, fns and ops.
· · · fix ⍝ Fix function/operator rep.
· · · fndiff ⍝ Defined function differences.
· · · fnrefs ⍝ External refs from function ⍵.
· · · fnrepl ⍝ Function string replacement.
· · · isdfn ⍝ Test for D function.
· · · nc ⍝ Extended ⎕NC for ojects named in ⍵.
· · · ncpath ⍝ ⎕path-aware ⎕nc.
· · · refmt ⍝ Reformat dfn/op.
· · · rep ⍝ Representation of function/operator.
· · · trace ⍝ Trace function application.
· · · UndoRedo ⍝ Derive undo/redo function.
·
· Files.
· ·
· · Native.files
· · · file ⍝ Apply operand function to native file tie.
· · · getfile ⍝ Get text file ⍵ as nested vector.
· · · hexdump ⍝ Hex dump of native file.
· · · putfile ⍝ Put rows to text-file.
· · · utf8 ⍝ ⎕AV ←→ UTF-8 translation.
· · · utf8get ⍝ Char vector from UTF-8 file ⍵.
· · · utf8put ⍝ Char vector ⍺ to UTF-8 file ⍵.
· · · xtabs ⍝ Expand/compress HT chars.
·
· · Component.files
· · · filefind ⍝ Find 'string' ⍵ in component file ⍺.
·
· Diversions.
· ·
· · · baby ⍝ The Manchester Small Scale Experimental Machine.
· · · bf ⍝ Brainfuck.
· · · dice ⍝ Interpret a throw of dice.
· · · draw ⍝ Draw over '*'s.
· · · life ⍝ John Conway's "Game of Life".
· · · keyboards ⍝ APL keyboard layouts.
· · · kt ⍝ Knight's Tour chess problem.
· · · mac ⍝ Simple Macro Processor for bf.
· · · mayan ⍝ Mayan numbers.
· · · maze ⍝ Kidz maze.
· · · mmind ⍝ Mastermind or "cows and bulls".
· · · morse ⍝ Conversion to/from Morse code.
· · · mp3 ⍝ Create playlist(s) for mp3 directories.
· · · queens ⍝ N-queens chess problem.
· · · quzzle ⍝ A hard, simple problem.
· · · ripple ⍝ Perfect Ripple Shuffle.
· · · roman ⍝ Roman numeral arithmetic.
· · · sudoku ⍝ Solution vector for Sudoku problem ⍵.
·
· Performance.
· ·
· · · cf ⍝ Ratio of operand timings.
· · · cmpx ⍝ Approx expression timings.
· · · mdf ⍝ Monitor D function.
· · · memo ⍝ Function memoization.
· · · ticks ⍝ Sample Dfn execution clock ticks.
· · · time ⍝ Time function application.
· · · wsreq ⍝ WS required to execute expression ⍵.
------------------------
Person and Topic Indexes
------------------------
Function [index] generates [person] and [topic] indexes from those lines in each
note that start with the character vector 'Index'. In addition, the note for
→index← contains lines starting Index≡, which supply aliases of the form: "For
this, see that".
-------------------------
A note on code appearance
-------------------------
The functions and operators in the workspace have been formatted to make them
easier to read. For example, the "else" operator should look like this:
else←{ ⍝ Condition f else g ...
⍺:⍺⍺ ⍵ ⍝ True: apply left operand.
⍵⍵ ⍵ ⍝ False: apply right operand.
}
If you have [AutoFormat functions] checked in the Options→Configure→Trace/Edit
tab, the system will impose its own canonical formatting style. This is OK, but
makes the functions look a little odd:
else←{ ⍝ Condition f else g ...
⍺:⍺⍺ ⍵ ⍝ True: apply left operand.
⍵⍵ ⍵ ⍝ False: apply right operand.
}
To see the code in its intended format, uncheck the box and try again.
------------
Highlighting
------------
Words in the notes may be distinguished by various styles of bracket:
→link← Link to another note; double-click or Shift-Enter to follow the link.
[bold] Function or argument name, equivalent to bold font.
_ital_ Emphasised word, equivalent to italic font.
-----------------------------
Dyalog Version considerations <V>
-----------------------------
The →test← scripts in this workspace contribute to Dyalog's nightly quality-
assurance (QA) process. For this reason, dfns.dws is maintained using the earli-
est supported version of the interpreter, currently V11. This means that some of
the more recent language features may not be used here. Places where this has an
impact on the code, for example, where improved methods have been avoided, are
noted with a version marker <V>. This serves as a reminder of which parts of the
workspace could be improved on migration to a newer version of the interpreter.
This expression lists all of the <V> lines:
{⎕←⍵ find'<V>'}¨refs # ⍝ display <V>-lines.
-------
Colours
-------
When viewing these notes from an APL session (as opposed to a web browser), you
can change their colours, see: →colour_change←.
--------------
Test namespace
--------------
Namespace "scripts" contains test scripts for most of the functions and operat-
ors in the workspace. See →test←.
-----------------
Printing dfns.dws
-----------------
The notes and code from this workspace can be found in a printable PDF form in:
http://www.dyalog.com/dfnsdws/DfnsNotes.pdf
http://www.dyalog.com/dfnsdws/DfnsCode.pdf
--------
Feedback
--------
Suggestions for extending or improving this workspace would be most welcome via
email to: john@dyalog.com.
See the "Functional Programming" forum in http://forums.dyalog.com.
Thanks for contributions from:
Adrian Smith
Blay Tarnoff
Bob Bernecky
Dag Dittmer
Dan Baronet
David Crossley
Dick Bowman
Gianluigi Quario
Geoff Streeter
Jay Foad
Jim Ryan
John B. Halleck
John Daintree
John Niss Hansen
John R. Clark
Jonathan Barman
Kai Jaeger
LeRoy N. Eide
Maria Wells
Mark Johns
Mayer Goldberg
Michael Kassler
Mike Day
Maurice Jordan
Michael Baas
Morten Kromberg
Nicolas Delcros
Paul Mansour
Perttu Pakarinen
Peter-Michael Hager
Phil Last
Ray Cannon
Reima Naumanen
Roger Hui
Stefano Lanzavecchia
Stephen Taylor
Steve Mansour
Veli-Matti Jantunen
Yves Bopp
Back to: Workspaces
Trouble seeing APL font?