|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
/*
* This file:
* http://anggtwu.net/myqdraw/myqdraw-core.mac.html
* http://anggtwu.net/myqdraw/myqdraw-core.mac
* (find-angg "myqdraw/myqdraw-core.mac")
* Author: Eduardo Ochs <eduardoochs@gmail.com>
* License: Public Domain
* Version: 2024nov05
*
* This is the core of all my attempts to extend qdraw - it is the
* part that hasn't changed from myqdraw1 to myqdraw3, except for
* minimal clean-ups. It is explained here:
*
* http://anggtwu.net/eev-qdraw.html#the-core
* http://anggtwu.net/eev-qdraw.html#eight-functions
*
* The functions of the cube that end with "v"
*
* qdraw ------ myqdraw
* | \ | \
* | qdraw1 | myqdraw1
* | | | |
* qdrawv |---- myqdrawv |
* \ | \ |
* qdraw1v ---- myqdraw1v
*
* use `concatvstrings'.
*
* «.mapconcat» (to "mapconcat")
* «.myqdraw» (to "myqdraw")
* «.eight-functions» (to "eight-functions")
* «.myapply» (to "myapply")
*/
/* «mapconcat» (to ".mapconcat")
* (find-es "maxima" "mapconcat")
* (find-maximanode "Introduction to Strings")
* (find-maximanode "Introduction to Strings" "Embedded line termination")
*/
newline : "
";
intercalate(sep, strs) :=
block([strs2, rest],
strs2: makelist(concat(sep,strs[i]), i,2,length(strs)),
rest: apply('concat, strs2),
concat(strs[1], rest))$
mapconcat(f,a,sep) := intercalate(sep, map(f,a))$
concatvstrings (L) := mapconcat('string, L, newline);
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("myqdraw-core.mac");
intercalate(",", ["a", "b", "c"]);
intercalate("_err_", []); "<- This gives an error"$
mapconcat(tex1, [x/y, z*w], " & ");
concatvstrings ([x/y, z*w]);
[x/y, z*w];
*/
/* «myqdraw» (to ".myqdraw")
* «eight-functions» (to ".eight-functions")
* (find-angg ".maxima/maxima-init.mac" "load_qdraw")
* (find-myqdrawfile "qdraw.mac")
* (find-myqdrawfile "qdraw.mac" "qdraw1" "produces drlist")
* (find-myqdrawfile "qdraw.mac" "qdraw calls qdraw1 then passes drlist")
*/
qdraw1v ([qargs]) := concatvstrings(apply('qdraw1, qargs));
qdrawv ([qargs]) := concatvstrings (qargs);
myqdraw_prep([qargs]) := flatten([qargs]);
myqdraw ([qargs]) := apply('qdraw, myqdraw_prep(qargs));
myqdraw1 ([qargs]) := apply('qdraw1, myqdraw_prep(qargs));
myqdraw1v ([qargs]) := apply('qdraw1v, myqdraw_prep(qargs));
myqdrawv ([qargs]) := apply('qdrawv, myqdraw_prep(qargs));
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-myqdraw "myqdraw3.mac")
load ("~/MAXIMA/myqdraw3.mac");
[p1, p2, p3] : [pts([[1,1]]), pts([[2,2]]), pts([[3,3]])];
qdraw1v (p1, p2, p3);
myqdraw1v([p1, [p2, p3]]);
myqdrawv ([p1, [p2, p3]]);
myqdraw ([p1, [p2, p3]]);
qdraw (p1, p2, p3);
*/
/*
* «myapply» (to ".myapply")
* See: (find-es "maxima" "myapply")
*/
butlast (L) := firstn(L, length(L)-1);
expandlast (L) := append(butlast(L), last(L));
flattenlast (L) := append(butlast(L), flatten([last(L)]));
myapply (f,[L]) := apply(f, expandlast(L));
myapply1 (f, L ) := apply(f, expandlast(L));
myapply1_fl(f, L ) := apply(f, flattenlast(L));
myapply_fl (f,[L]) := apply(f, flattenlast(L));
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("myqdraw-core.mac");
butlast ([1,2,3,4,[[5,6],[7,8]]]);
expandlast ([1,2,3,4,[[5,6],[7,8]]]);
flattenlast([1,2,3,4,[[5,6],[7,8]]]);
apply (foo, [[x0,y0],[x1,y1]]);
myapply (foo, [x0,y0],[x1,y1], [[2,3],[4,5]] );
myapply1 (foo, [[x0,y0],[x1,y1], [[2,3],[4,5]]]);
myapply1_fl(foo, [[x0,y0],[x1,y1], [[2,3],[4,5]]]);
*/
/*
* Local Variables:
* coding: utf-8-unix
* End:
*/