1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16if known metafun_loaded_func : endinput ; fi ;
17
18newinternal boolean metafun_loaded_func ; metafun_loaded_func := true ; immutable metafun_loaded_func ;
19
20string mfun_pathconnectors[] ;
21
22mfun_pathconnectors[0] := "," ;
23mfun_pathconnectors[1] := "--" ;
24mfun_pathconnectors[2] := ".." ;
25mfun_pathconnectors[3] := "..." ;
26mfun_pathconnectors[4] := "---" ;
27
28def pathconnectors = mfun_pathconnectors enddef ;
29
30vardef mfun_function (expr f) (expr u, t, b, e, s) =
31 save x ; numeric x ;
32 save c ; string c ; c := if string f : f else : mfun_pathconnectors[f] fi ;
33 for xx := b step s until e :
34 hide (x := xx ;)
35 if xx > b :
36 scantokens(c)
37 fi
38 (scantokens(u),scantokens(t))
39 endfor
40enddef ;
41
42def function = mfun_function enddef ;
43def constructedfunction = mfun_function enddef ;
44def straightfunction = mfun_function (1) enddef ;
45def curvedfunction = mfun_function (2) enddef ;
46
47
48
49
50vardef mfun_constructedpath (expr f) (text t) =
51 save ok ; boolean ok ; ok := false ;
52 save c ; string c ; c := if string f : f else : mfun_pathconnectors[f] fi ;
53 for i=t :
54 if ok :
55 scantokens(c)
56 else :
57 ok := true ;
58 fi
59 i
60 endfor
61enddef ;
62
63def constructedpath = mfun_constructedpath enddef ;
64def straightpath = mfun_constructedpath (1) enddef ;
65def curvedpath = mfun_constructedpath (2) enddef ;
66
67
68
69
70vardef mfun_constructedpairs (expr f) (text p) =
71 save i ; i := -1 ;
72 save c ; string c ; c := if string f : f else : mfun_pathconnectors[f] fi ;
73 forever :
74 exitif unknown p[incr(i)] ;
75 if i>0 :
76 scantokens(c)
77 fi
78 p[i]
79 endfor
80enddef ;
81
82def constructedpairs = mfun_constructedpairs enddef ;
83def straightpairs = mfun_constructedpairs (1) enddef ;
84def curvedpairs = mfun_constructedpairs (2) enddef ;
85
86
87
88 |