Skip to content

Commit

Permalink
mop$ maps function to elements of expression & outputs space separate…
Browse files Browse the repository at this point in the history
…d list
  • Loading branch information
BartJongejan committed May 2, 2022
1 parent 18eb96f commit 3c6d3c9
Show file tree
Hide file tree
Showing 10 changed files with 1,720 additions and 1,762 deletions.
7 changes: 3 additions & 4 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
2 May 2022
map$ can now handle a non-list expression as though it were a list. For that,
there is an extra argument telling on what type of operator to split the
expression.
E.g. map$((=.!arg) 2*a+i*b+e\Lc (=+))
New built-in function mop$ iterates over terms/factors/elements and outputs a
space operator separated list.
E.g. mop$((=.!arg).2*a+i*b+e\Lc.(=+))
evaluates to 2*a e\Lc i*b

26 October 2021
Expand Down
2,362 changes: 1,105 additions & 1,257 deletions doc/bracmat-table.html

Large diffs are not rendered by default.

389 changes: 194 additions & 195 deletions doc/bracmat.html

Large diffs are not rendered by default.

Binary file removed doc/bracmat.pdf
Binary file not shown.
47 changes: 39 additions & 8 deletions doc/bracmat.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3295,7 +3295,7 @@ \subsection{Built-in functions}
Returns the current value of the file position indicator.
\bfun{\bc{fil\d(}\bi{file-ame}\bc,\bi{whence}\bc,\bi{offset}\bc)}
\bfun{\bc{fil\d(}\bi{file-name}\bc,\bi{whence}\bc,\bi{offset}\bc)}
Go to file position.
Expand Down Expand Up @@ -3646,20 +3646,51 @@ \subsection{Built-in functions}
_oct{!} 1 4 9 16
{?} ( map
_d[] ( (
= x
. !arg:?*?^%?x*?*?^!x*?
& (!arg."same exponent" !x)
| (!arg.)
)
. a*b^3*c^2 d*f^3*g^2*h*j^3 o*p
)
= x
. !arg:?*?^%?x*?*?^!x*?
& (!arg."same exponent" !x)
| (!arg.)
)
. a*b^3*c^2 d*f^3*g^2*h*j^3 o*p
)
)
_oct{!} (a*b^3*c^2.)
_oct (d*f^3*g^2*h*j^3.same exponent 3)
_oct (o*p.)
\end{ex}
\bfun{\bc{mop\d(}\bi{fnc}.\bi{expression}.(=\bi{non-leaf expression}\bc))}
\index{mop@\bc{mop}}
\verb|mop$| traverses a list-like expression element by element and outputs a space
operator separated list. For that to work, \verb|mop$| needs an extra argument that
tells which operator to use. That argument is always headed by \verb|=|, the
right hand side of which is a non-leaf expression. The top operator of that
expression is used as the separating operator.
\begin{ex}
{?} mop_d((=.!arg).aap+noot+mies.(=+))
_oct{!} aap mies noot
{?} (x=2*a+i*b+e\Lc) & mop_d((=.!arg).!x.()'($x))
_oct{!} 2*a e\Lc c i*b
_oct{!}
\end{ex}
It is possible to have a list with space operators as separating operator:
\begin{ex}
{?} mop'((=.!arg).a b c.(=x y))
_oct{!} a b c
\end{ex}
Another way to do this is to use the \verb|map$| function
\begin{ex}
{?} map'((=.!arg).a b c)
{!} a b c
\end{ex}
\bfun{\bc{mem\d}[\bc{EXT}]}
\index{mem@\bc{mem}}
\verb|mem$| produces a list of all currently existing variables,
Expand Down
99 changes: 64 additions & 35 deletions doc/help
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ help=
. varmattxt,varprotxt,progsmenu,debugtxt,debugtxt2,debugtxt3
. inbltmenu,alctxt,aligntxt,asctxt,utftxt,chrtxt,charset
. chutxt,dbgtxt,dentxt,escappattxt,lambda,morexmlps,jsntxt
. divtxt,fretxt,funtxt1,funtxt3,beztxt
. divtxt,fretxt,funtxt1,funtxt3,beztxt,moptxt
. lsttxt1,difftxt,pattxt2,methodtxt,predvartxt
. lsttxt2,lsttxt3,memtxt,modtxt,peetxt,poktxt,Bracmat-name
. puttxt1,puttxt2,puttxt3,rentxt,revtxt,seltxt,simtxt,strtxt
Expand Down Expand Up @@ -179,39 +179,41 @@ lex lexical analysis of help file"
list existing variable names
22 |_mod_|
remainder
23 |_new_|
23 |_mop_|
map expression to space separated list
24 |_new_|
create new object as a copy of another object
24 |_pee_|
25 |_pee_|
get value from address (peek) (low level)
25 |_pok_|
26 |_pok_|
put value at address (poke) (low level)
26 |_put_|
27 |_put_|
write output
27 |_ren_|
28 |_ren_|
rename file or directory or move file
28 |_rev_|
29 |_rev_|
string reverse
29 |_rmv_|
30 |_rmv_|
remove file
30 |_sim_|
31 |_sim_|
similarity between two atoms
31 |_str_|
32 |_str_|
stringize expression into atom
32 |_swi_|
33 |_swi_|
software interrupt (low level)
33 |_sys_|
34 |_sys_|
command line shell
34 |_tbl_|
35 |_tbl_|
create array, remove array/variable
35 |_upp_|
36 |_upp_|
convert to upper case
36 |_utf_|
37 |_utf_|
convert UTF-8 character to Unicode codepoint
37 |_vap_|
38 |_vap_|
deconstruct a string character-wise or according to specified separator
38 |_whl_|
39 |_whl_|
while loop
39 |_x2d_|
40 |_x2d_|
convert hexadecimal number to decimal number x2d$BABEFACE:3133078222
"
, (1,seltxt)
Expand All @@ -236,23 +238,24 @@ lex lexical analysis of help file"
(20,maptxt)
(21,memtxt)
(22,modtxt)
(23,newobjecttxt)
(24,peetxt)
(25,poktxt)
(26,puttxt1 humtxt puttxt2 puttxt3 newtxt)
(27,rentxt)
(28,rmvtxt)
(29,revtxt)
(30,simtxt)
(31,strtxt)
(32,switxt)
(33,systxt)
(34,tbltxt)
(35,upptxt DOSopttxt)
(36,utftxt)
(37,vaptxt)
(38,whltxt)
(39,x2dtxt)
(23,moptxt)
(24,newobjecttxt)
(25,peetxt)
(26,poktxt)
(27,puttxt1 humtxt puttxt2 puttxt3 newtxt)
(28,rentxt)
(29,rmvtxt)
(30,revtxt)
(31,simtxt)
(32,strtxt)
(33,switxt)
(34,systxt)
(35,tbltxt)
(36,upptxt DOSopttxt)
(37,utftxt)
(38,vaptxt)
(39,whltxt)
(40,x2dtxt)
)
& ( intro
= M
Expand Down Expand Up @@ -3665,6 +3668,32 @@ separated by the space operator.
(d*f^3*g^2*h*j^3.same exponent 3)
(o*p.)"
)
& ( moptxt
= T
, "mop$(<fnc>.<expression>.(=<non-leaf expression>))"
, "mop$ traverses a list-like expression element by element and outputs a space
operator separated list. For that to work, mop$ needs an extra argument that
tells which operator to use. That argument is always headed by |_=_|, the
right hand side of which is a non-leaf expression. The top operator of that
expression is used as the separating operator.
{?} mop$((=.!arg).aap+noot+mies.(=+))
{!} aap mies noot
{?} (x=2*a+i*b+e\Lc) & mop$((=.!arg).!x.()'($x))
{!} 2*a e\Lc i*b
{?} mop$((=.!arg)..(=*))
{!}

It is possible to have a list with space operators as separating operator:

{?} mop'((=.!arg).a b c.(=x y))
{!} a b c

Another way to do this is to use the map$ function

{?} map'((=.!arg).a b c)
{!} a b c
"
)
& ( vaptxt
= T
, "vap$(<fnc>.<string>) or vap$(<fnc>.<string>.<separator>)"
Expand Down
Loading

0 comments on commit 3c6d3c9

Please sign in to comment.