markdown as an accessible, literate programming language
death to psuedocode, long live psuedocode.
%% html
< iframe allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen = "" frameborder = "0" height = "315" referrerpolicy = "strict-origin-when-cross-origin" src = "https://www.youtube.com/embed/rmgJ5oNxQDA?si=xSpkJS5-fRSKcmok" title = "YouTube video player" width = "560" ></ iframe >
VIDEO
%%
these are links we collected talking about calligraphy and code .
links = Series \
- [ patron saint of yak shaves ]( https : // yakshav . es / the - patron - saint - of - yakshaves / )
- [ quanta magazine : The Computer Scientist Who Can ’ t Stop Telling Stories ]( https : // www . quantamagazine . org / computer - scientist - donald - knuth - cant - stop - telling - stories - 20200416 / )
- [ literate programming ]( http : // www . literateprogramming . com / knuthweb . pdf )
- [ Understanding Computer Programming as a Literacy ]( https : // licsjournal . org / index . php / LiCS / article / view / 794 / 609 )
- [ science vs literature ]( #)
- [ the letter s ]( https : // gwern . net / doc / design / typography / 1980 - knuth . pdf )
- [ the unravelled calligram - foucault ]( https : // monoskop . org / images / 9 / 99 / Foucault_Michel_This_Is_Not_a_Pipe . pdf )
these are links we collected talking about calligraphy and code.
links = Series\
> There is, finally between science and literature, a third margin which science must reconquer, that of pleasure .
My hope is that the ability to make explanations more nat-
ural will cause more programmers to discover the joys
of literate programming, because I believe it’s quite a
pleasure to combine verbal and mathematical skills; but
perhaps I’m hoping for too much.
![](https://i.pinimg.com/736x/cb/51/33/cb5133c2406fd5ee52b9cc437a618174.jpg)
calligraphy by [herman zapf](https://en.wikipedia.org/wiki/Hermann_Zapf)
live code
def to_vars ( row ):
return pipe (
{ "index" : row . name } | dict ( row ),
dict . items ,
map ( "-- %s : %f ;" . __mod__ ), " " . join )
%%
df = DataFrame ( index = Index ( range ( 360 ), name = "index" ))
df = df . assign (
sin = ( df . index * numpy . pi / 180 ) . map ( numpy . sin ),
cos = ( df . index * numpy . pi / 180 ) . map ( numpy . cos ),
)
< style >
#dance {
width : 50 vw ;
tr {
display : flex ;
}
td , th {
display : block ;
position : relative ;
transform : translateX ( calc ( var ( -- this ) * 100 % ));
}
}
</ style >
< table id = "dance" >
< caption > waves </ caption >
< thead > { % for column in list ( df . index . names ) + list ( df . columns ) % } < th > {{ column }} </ th > { % endfor % } </ thead >
< tbody > { % for i , row in df . iterrows () % } < tr style = "{{to_vars(row)}}" >
< th > {{ df . loc [ i ] . name }} </ th >
{ % for column in df . columns % } < td style = "--this: var(--{{column}});" > {{ row . loc [ column ]}} </ td > { % endfor % }
</ tr > { % endfor % }
</ tbody >
</ table >
df = DataFrame(index=Index(range(360), name="index"))
df = df.assign(
sin=(df.index * numpy.pi / 180).map(numpy.sin),
cos=(df.index * numpy.pi / 180).map(numpy.cos),
)
waves
index sin cos
0
0.0 1.0
1
0.01745240643728351 0.9998476951563913
2
0.03489949670250097 0.9993908270190958
3
0.05233595624294383 0.9986295347545738
4
0.0697564737441253 0.9975640502598242
5
0.08715574274765817 0.9961946980917455
6
0.10452846326765346 0.9945218953682733
7
0.12186934340514748 0.992546151641322
8
0.13917310096006544 0.9902680687415704
9
0.15643446504023087 0.9876883405951378
10
0.17364817766693033 0.984807753012208
11
0.1908089953765448 0.981627183447664
12
0.20791169081775931 0.9781476007338057
13
0.224951054343865 0.9743700647852352
14
0.24192189559966773 0.9702957262759965
15
0.25881904510252074 0.9659258262890683
16
0.27563735581699916 0.9612616959383189
17
0.29237170472273677 0.9563047559630354
18
0.3090169943749474 0.9510565162951535
19
0.32556815445715664 0.9455185755993168
20
0.3420201433256687 0.9396926207859084
21
0.35836794954530027 0.9335804264972017
22
0.374606593415912 0.9271838545667874
23
0.3907311284892737 0.9205048534524404
24
0.40673664307580015 0.9135454576426009
25
0.42261826174069944 0.9063077870366499
26
0.4383711467890774 0.898794046299167
27
0.45399049973954675 0.8910065241883679
28
0.4694715627858908 0.882947592858927
29
0.48480962024633706 0.8746197071393957
30
0.49999999999999994 0.8660254037844387
31
0.5150380749100542 0.8571673007021123
32
0.5299192642332049 0.848048096156426
33
0.5446390350150271 0.838670567945424
34
0.5591929034707469 0.8290375725550416
35
0.573576436351046 0.8191520442889918
36
0.5877852522924731 0.8090169943749475
37
0.6018150231520483 0.7986355100472928
38
0.6156614753256582 0.788010753606722
39
0.6293203910498374 0.7771459614569709
40
0.6427876096865393 0.766044443118978
41
0.6560590289905072 0.7547095802227721
42
0.6691306063588582 0.7431448254773942
43
0.6819983600624985 0.7313537016191706
44
0.6946583704589973 0.7193398003386512
45
0.7071067811865475 0.7071067811865476
46
0.7193398003386511 0.6946583704589974
47
0.7313537016191705 0.6819983600624985
48
0.7431448254773941 0.6691306063588582
49
0.754709580222772 0.6560590289905073
50
0.766044443118978 0.6427876096865394
51
0.7771459614569708 0.6293203910498375
52
0.788010753606722 0.6156614753256583
53
0.7986355100472928 0.6018150231520484
54
0.8090169943749475 0.5877852522924731
55
0.8191520442889918 0.5735764363510462
56
0.8290375725550417 0.5591929034707468
57
0.8386705679454239 0.5446390350150272
58
0.848048096156426 0.5299192642332049
59
0.8571673007021122 0.5150380749100544
60
0.8660254037844386 0.5000000000000001
61
0.8746197071393957 0.4848096202463371
62
0.8829475928589269 0.46947156278589086
63
0.8910065241883678 0.4539904997395468
64
0.898794046299167 0.43837114678907746
65
0.9063077870366499 0.42261826174069944
66
0.9135454576426009 0.4067366430758002
67
0.9205048534524403 0.39073112848927394
68
0.9271838545667874 0.37460659341591196
69
0.9335804264972017 0.3583679495453004
70
0.9396926207859083 0.3420201433256688
71
0.9455185755993167 0.32556815445715676
72
0.9510565162951535 0.30901699437494745
73
0.9563047559630354 0.29237170472273677
74
0.9612616959383189 0.27563735581699916
75
0.9659258262890683 0.25881904510252074
76
0.9702957262759965 0.2419218955996679
77
0.9743700647852352 0.22495105434386492
78
0.9781476007338056 0.20791169081775945
79
0.981627183447664 0.19080899537654492
80
0.984807753012208 0.17364817766693041
81
0.9876883405951378 0.15643446504023092
82
0.9902680687415703 0.1391731009600657
83
0.992546151641322 0.12186934340514749
84
0.9945218953682733 0.10452846326765346
85
0.9961946980917455 0.08715574274765814
86
0.9975640502598242 0.06975647374412546
87
0.9986295347545738 0.052335956242943966
88
0.9993908270190958 0.03489949670250108
89
0.9998476951563913 0.017452406437283376
90
1.0 6.123233995736766e-17
91
0.9998476951563913 -0.017452406437283477
92
0.9993908270190958 -0.03489949670250073
93
0.9986295347545738 -0.05233595624294362
94
0.9975640502598242 -0.06975647374412533
95
0.9961946980917455 -0.08715574274765824
96
0.9945218953682734 -0.10452846326765333
97
0.9925461516413221 -0.12186934340514737
98
0.9902680687415704 -0.13917310096006535
99
0.9876883405951377 -0.15643446504023104
100
0.984807753012208 -0.1736481776669303
101
0.981627183447664 -0.1908089953765448
102
0.9781476007338057 -0.20791169081775912
103
0.9743700647852352 -0.2249510543438648
104
0.9702957262759965 -0.24192189559966779
105
0.9659258262890683 -0.25881904510252085
106
0.9612616959383189 -0.27563735581699905
107
0.9563047559630355 -0.29237170472273666
108
0.9510565162951536 -0.30901699437494734
109
0.9455185755993168 -0.3255681544571564
110
0.9396926207859084 -0.3420201433256687
111
0.9335804264972017 -0.35836794954530027
112
0.9271838545667874 -0.37460659341591207
113
0.9205048534524404 -0.3907311284892736
114
0.913545457642601 -0.40673664307580004
115
0.90630778703665 -0.42261826174069933
116
0.8987940462991669 -0.4383711467890775
117
0.8910065241883679 -0.4539904997395467
118
0.8829475928589271 -0.46947156278589053
119
0.8746197071393959 -0.484809620246337
120
0.8660254037844387 -0.4999999999999998
121
0.8571673007021123 -0.5150380749100543
122
0.8480480961564261 -0.5299192642332048
123
0.8386705679454239 -0.5446390350150271
124
0.8290375725550417 -0.5591929034707467
125
0.819152044288992 -0.5735764363510458
126
0.8090169943749475 -0.587785252292473
127
0.7986355100472927 -0.6018150231520484
128
0.788010753606722 -0.6156614753256583
129
0.777145961456971 -0.6293203910498373
130
0.766044443118978 -0.6427876096865394
131
0.7547095802227718 -0.6560590289905075
132
0.7431448254773942 -0.6691306063588582
133
0.7313537016191706 -0.6819983600624984
134
0.7193398003386514 -0.694658370458997
135
0.7071067811865476 -0.7071067811865475
136
0.6946583704589971 -0.7193398003386512
137
0.6819983600624986 -0.7313537016191705
138
0.6691306063588583 -0.743144825477394
139
0.6560590289905073 -0.754709580222772
140
0.6427876096865395 -0.7660444431189779
141
0.6293203910498377 -0.7771459614569707
142
0.6156614753256584 -0.7880107536067219
143
0.6018150231520482 -0.7986355100472929
144
0.5877852522924732 -0.8090169943749473
145
0.5735764363510464 -0.8191520442889916
146
0.5591929034707469 -0.8290375725550416
147
0.544639035015027 -0.8386705679454242
148
0.5299192642332049 -0.848048096156426
149
0.5150380749100544 -0.8571673007021122
150
0.49999999999999994 -0.8660254037844387
151
0.48480962024633717 -0.8746197071393957
152
0.4694715627858911 -0.8829475928589268
153
0.45399049973954686 -0.8910065241883678
154
0.4383711467890773 -0.898794046299167
155
0.4226182617406995 -0.9063077870366499
156
0.40673664307580043 -0.9135454576426008
157
0.39073112848927416 -0.9205048534524402
158
0.37460659341591224 -0.9271838545667873
159
0.3583679495453002 -0.9335804264972017
160
0.3420201433256689 -0.9396926207859083
161
0.32556815445715703 -0.9455185755993167
162
0.3090169943749475 -0.9510565162951535
163
0.29237170472273705 -0.9563047559630354
164
0.27563735581699966 -0.9612616959383187
165
0.258819045102521 -0.9659258262890682
166
0.24192189559966773 -0.9702957262759965
167
0.22495105434386478 -0.9743700647852352
168
0.20791169081775931 -0.9781476007338057
169
0.19080899537654497 -0.981627183447664
170
0.17364817766693028 -0.984807753012208
171
0.15643446504023098 -0.9876883405951377
172
0.13917310096006574 -0.9902680687415703
173
0.12186934340514755 -0.992546151641322
174
0.10452846326765373 -0.9945218953682733
175
0.08715574274765864 -0.9961946980917455
176
0.06975647374412552 -0.9975640502598242
177
0.05233595624294381 -0.9986295347545738
178
0.0348994967025007 -0.9993908270190958
179
0.01745240643728344 -0.9998476951563913
180
1.2246467991473532e-16 -1.0
181
-0.017452406437283192 -0.9998476951563913
182
-0.0348994967025009 -0.9993908270190958
183
-0.052335956242943564 -0.9986295347545738
184
-0.06975647374412483 -0.9975640502598243
185
-0.08715574274765794 -0.9961946980917455
186
-0.10452846326765305 -0.9945218953682734
187
-0.12186934340514774 -0.992546151641322
188
-0.13917310096006552 -0.9902680687415703
189
-0.15643446504023073 -0.9876883405951378
190
-0.17364817766693047 -0.984807753012208
191
-0.19080899537654472 -0.981627183447664
192
-0.20791169081775907 -0.9781476007338057
193
-0.22495105434386498 -0.9743700647852352
194
-0.2419218955996675 -0.9702957262759965
195
-0.25881904510252035 -0.9659258262890684
196
-0.275637355816999 -0.9612616959383189
197
-0.2923717047227364 -0.9563047559630355
198
-0.30901699437494773 -0.9510565162951535
199
-0.32556815445715676 -0.9455185755993167
200
-0.34202014332566866 -0.9396926207859084
201
-0.35836794954530043 -0.9335804264972017
202
-0.374606593415912 -0.9271838545667874
203
-0.39073112848927355 -0.9205048534524404
204
-0.4067366430757998 -0.9135454576426011
205
-0.4226182617406993 -0.90630778703665
206
-0.43837114678907707 -0.8987940462991671
207
-0.45399049973954625 -0.8910065241883681
208
-0.46947156278589086 -0.8829475928589269
209
-0.48480962024633695 -0.8746197071393959
210
-0.5000000000000001 -0.8660254037844386
211
-0.5150380749100542 -0.8571673007021123
212
-0.5299192642332048 -0.8480480961564261
213
-0.5446390350150271 -0.838670567945424
214
-0.5591929034707467 -0.8290375725550418
215
-0.5735764363510458 -0.819152044288992
216
-0.587785252292473 -0.8090169943749476
217
-0.601815023152048 -0.798635510047293
218
-0.6156614753256578 -0.7880107536067222
219
-0.6293203910498376 -0.7771459614569708
220
-0.6427876096865393 -0.766044443118978
221
-0.6560590289905074 -0.7547095802227719
222
-0.6691306063588582 -0.7431448254773942
223
-0.6819983600624984 -0.7313537016191706
224
-0.6946583704589974 -0.7193398003386511
225
-0.7071067811865475 -0.7071067811865477
226
-0.7193398003386509 -0.6946583704589976
227
-0.7313537016191701 -0.6819983600624989
228
-0.743144825477394 -0.6691306063588585
229
-0.7547095802227717 -0.6560590289905076
230
-0.7660444431189779 -0.6427876096865395
231
-0.7771459614569711 -0.6293203910498372
232
-0.7880107536067221 -0.6156614753256581
233
-0.7986355100472928 -0.6018150231520483
234
-0.8090169943749473 -0.5877852522924732
235
-0.8191520442889916 -0.5735764363510464
236
-0.8290375725550414 -0.5591929034707472
237
-0.838670567945424 -0.544639035015027
238
-0.848048096156426 -0.529919264233205
239
-0.8571673007021121 -0.5150380749100545
240
-0.8660254037844384 -0.5000000000000004
241
-0.874619707139396 -0.48480962024633684
242
-0.882947592858927 -0.46947156278589075
243
-0.8910065241883678 -0.4539904997395469
244
-0.8987940462991668 -0.43837114678907774
245
-0.9063077870366497 -0.42261826174069994
246
-0.913545457642601 -0.4067366430758001
247
-0.9205048534524403 -0.3907311284892738
248
-0.9271838545667873 -0.3746065934159123
249
-0.9335804264972016 -0.3583679495453007
250
-0.9396926207859082 -0.3420201433256694
251
-0.9455185755993168 -0.32556815445715664
252
-0.9510565162951535 -0.30901699437494756
253
-0.9563047559630353 -0.2923717047227371
254
-0.961261695938319 -0.2756373558169989
255
-0.9659258262890683 -0.25881904510252063
256
-0.9702957262759965 -0.24192189559966779
257
-0.9743700647852351 -0.22495105434386525
258
-0.9781476007338056 -0.2079116908177598
259
-0.9816271834476639 -0.19080899537654547
260
-0.984807753012208 -0.17364817766693033
261
-0.9876883405951377 -0.15643446504023104
262
-0.9902680687415704 -0.13917310096006494
263
-0.9925461516413221 -0.12186934340514717
264
-0.9945218953682734 -0.10452846326765336
265
-0.9961946980917455 -0.08715574274765825
266
-0.9975640502598242 -0.06975647374412558
267
-0.9986295347545738 -0.052335956242944306
268
-0.9993908270190957 -0.03489949670250165
269
-0.9998476951563913 -0.017452406437283498
270
-1.0 -1.8369701987210297e-16
271
-0.9998476951563913 0.01745240643728313
272
-0.9993908270190958 0.03489949670250128
273
-0.9986295347545738 0.052335956242943946
274
-0.9975640502598243 0.06975647374412522
275
-0.9961946980917455 0.08715574274765789
276
-0.9945218953682734 0.10452846326765299
277
-0.992546151641322 0.12186934340514768
278
-0.9902680687415704 0.13917310096006547
279
-0.9876883405951378 0.15643446504023067
280
-0.9848077530122081 0.17364817766692997
281
-0.9816271834476641 0.19080899537654425
282
-0.9781476007338058 0.20791169081775857
283
-0.9743700647852352 0.22495105434386492
284
-0.9702957262759966 0.24192189559966745
285
-0.9659258262890682 0.25881904510252113
286
-0.9612616959383188 0.2756373558169994
287
-0.9563047559630354 0.2923717047227367
288
-0.9510565162951536 0.30901699437494723
289
-0.945518575599317 0.3255681544571563
290
-0.9396926207859085 0.34202014332566816
291
-0.9335804264972021 0.35836794954529955
292
-0.9271838545667874 0.37460659341591196
293
-0.9205048534524405 0.3907311284892735
294
-0.9135454576426008 0.40673664307580054
295
-0.9063077870366499 0.4226182617406996
296
-0.898794046299167 0.4383711467890774
297
-0.891006524188368 0.45399049973954664
298
-0.8829475928589271 0.4694715627858904
299
-0.8746197071393961 0.4848096202463365
300
-0.8660254037844386 0.5000000000000001
301
-0.8571673007021123 0.5150380749100542
302
-0.8480480961564262 0.5299192642332047
303
-0.8386705679454243 0.5446390350150266
304
-0.8290375725550421 0.5591929034707462
305
-0.8191520442889918 0.573576436351046
306
-0.8090169943749476 0.5877852522924729
307
-0.798635510047293 0.6018150231520479
308
-0.7880107536067218 0.6156614753256585
309
-0.7771459614569708 0.6293203910498375
310
-0.7660444431189781 0.6427876096865393
311
-0.7547095802227722 0.656059028990507
312
-0.7431448254773946 0.6691306063588578
313
-0.731353701619171 0.681998360062498
314
-0.7193398003386517 0.6946583704589966
315
-0.7071067811865477 0.7071067811865474
316
-0.6946583704589976 0.7193398003386509
317
-0.6819983600624983 0.7313537016191707
318
-0.6691306063588581 0.7431448254773942
319
-0.6560590289905074 0.7547095802227719
320
-0.6427876096865396 0.7660444431189778
321
-0.6293203910498378 0.7771459614569706
322
-0.6156614753256588 0.7880107536067216
323
-0.6018150231520483 0.7986355100472928
324
-0.5877852522924734 0.8090169943749473
325
-0.5735764363510465 0.8191520442889916
326
-0.5591929034707473 0.8290375725550414
327
-0.544639035015027 0.838670567945424
328
-0.5299192642332058 0.8480480961564254
329
-0.5150380749100545 0.8571673007021121
330
-0.5000000000000004 0.8660254037844384
331
-0.4848096202463369 0.8746197071393959
332
-0.4694715627858908 0.8829475928589269
333
-0.45399049973954697 0.8910065241883678
334
-0.438371146789077 0.8987940462991671
335
-0.4226182617407 0.9063077870366497
336
-0.40673664307580015 0.913545457642601
337
-0.3907311284892747 0.9205048534524399
338
-0.37460659341591235 0.9271838545667873
339
-0.35836794954530077 0.9335804264972015
340
-0.3420201433256686 0.9396926207859084
341
-0.32556815445715753 0.9455185755993165
342
-0.3090169943749476 0.9510565162951535
343
-0.29237170472273627 0.9563047559630357
344
-0.2756373558169998 0.9612616959383187
345
-0.2588190451025207 0.9659258262890683
346
-0.24192189559966787 0.9702957262759965
347
-0.22495105434386534 0.9743700647852351
348
-0.20791169081775987 0.9781476007338056
349
-0.19080899537654467 0.981627183447664
350
-0.17364817766693127 0.9848077530122079
351
-0.15643446504023112 0.9876883405951377
352
-0.13917310096006588 0.9902680687415703
353
-0.12186934340514811 0.992546151641322
354
-0.10452846326765342 0.9945218953682733
355
-0.08715574274765832 0.9961946980917455
356
-0.06975647374412476 0.9975640502598243
357
-0.05233595624294437 0.9986295347545738
358
-0.034899496702500823 0.9993908270190958
359
-0.01745240643728445 0.9998476951563913
def attrs ( str ):
soup = __import__ ( "bs4" ) . BeautifulSoup ( str , features = "lxml" )
return soup . a . attrs | { "text" : soup . a . string }
links . apply ( shell . tangle . parser . parser . render ) . apply (
attrs
) . series ()
href
text
0
https://yakshav.es/the-patron-saint-of-yakshaves/
patron saint of yak shaves
1
https://www.quantamagazine.org/computer-scient...
quanta magazine: The Computer Scientist Who Ca...
2
http://www.literateprogramming.com/knuthweb.pdf
literate programming
3
https://licsjournal.org/index.php/LiCS/article...
Understanding Computer Programming as a Literacy
4
#
science vs literature
5
https://gwern.net/doc/design/typography/1980-k...
the letter s
6
https://monoskop.org/images/9/99/Foucault_Mich...
the unravelled calligram - foucault
%%
we can save complex markdown objects as variables
table_source = \
| | href | text |
|--- : | : ---------------------------------------------------------------------------------------------------| : -----------------------------------------------------------------------|
| 0 | https : // yakshav . es / the - patron - saint - of - yakshaves / | patron saint of yak shaves |
| 1 | https : // www . quantamagazine . org / computer - scientist - donald - knuth - cant - stop - telling - stories - 20200416 / | quanta magazine : The Computer Scientist Who Can ’ t Stop Telling Stories |
| 2 | http : // www . literateprogramming . com / knuthweb . pdf | literate programming |
| 3 | https : // licsjournal . org / index . php / LiCS / article / view / 794 / 609 | Understanding Computer Programming as a Literacy |
| 4 | # | science vs literature |
| 5 | https : // gwern . net / doc / design / typography / 1980 - knuth . pdf | the letter s |
then we can recover the data from markdown and mark it useful without redundant work .
pipe (
table_source ,
shell . tangle . parser . parser . render ,
io . StringIO ,
pandas . read_html ,
first
)
Unnamed: 0
href
text
0
0
https://yakshav.es/the-patron-saint-of-yakshaves/
patron saint of yak shaves
1
1
https://www.quantamagazine.org/computer-scient...
quanta magazine: The Computer Scientist Who Ca...
2
2
http://www.literateprogramming.com/knuthweb.pdf
literate programming
3
3
https://licsjournal.org/index.php/LiCS/article...
Understanding Computer Programming as a Literacy
4
4
#
science vs literature
5
5
https://gwern.net/doc/design/typography/1980-k...
the letter s
we can save complex markdown objects as variables
table_source=\
then we can recover the data from markdown and mark it useful without redundant work.
pipe(
table_source,
shell.tangle.parser.parser.render,
io.StringIO,
pandas.read_html,
first
)