-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.qmd
2807 lines (2173 loc) · 115 KB
/
index.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
#title: "Savings Calculator"
#author: "Declan"
format:
dashboard:
resources:
- ./gallery.yml
- /models/raycasting/raycasting*.js
- /models/raycasting/**
nav-buttons:
- icon: github
href: https://github.com/declann/calculang-at-fosdem
- text: Slides
href: /slides.html
- text: Viz API
href: https://calcuvizspec-presentation.pages.dev/calcuvizspec-revealjs
- text: calculang.dev
href: https://calculang.dev
- text: Reactive Workings
href: /reactive-workings-notes.html
- icon: twitter
href: https://twitter.com/calculang
- icon: mastodon
href: https://fosstodon.org/@calculang
code-fold: true
code-summary: "Show the code"
orientation: columns
include-in-header:
text: <script type="module"> if (!("anchorName" in document.documentElement.style)) { import("https://unpkg.com/@oddbird/css-anchor-positioning"); }</script>
# ? scrolling: true ?
---
```{ojs}
//| output: false
// raycasting
viewof player_x_in = Inputs.input(1.7)
viewof player_y_in = Inputs.input(5.5)
viewof ray_angle_in = Inputs.input(999)
viewof fisheye_correction_in = Inputs.input(true)
viewof step_in = Inputs.input(0)
viewof x_in = Inputs.input(3.5)
viewof y_in = Inputs.input(3.5)
viewof f_in = Inputs.input(0)
viewof key_stream_version_in = Inputs.input(0)
viewof keys_stream_version_in = Inputs.input("hi")
// emissions-savings interactions using year for different meanings destroys eachother
viewof emissions_year_in = Inputs.input(2024)
// savings
viewof annual_payment_in = Inputs.input(1000)
viewof duration_in = Inputs.input(5)
viewof interest_rate_in = Inputs.input(.02)
viewof year_in = Inputs.input(modelname == 'simple_loan' ? 1 : 5)
viewof i_in = Inputs.input(modelname == 'fizzbuzz' ? 0 : +(q.get('i_in')??0.04)/1) // vs 2 for fizzbuzz!!
viewof date_in = Inputs.input(new Date())
viewof now_in = Inputs.input(new Date())
viewof timing_in = Inputs.input(modelname == 'emissions_my_lifetime' ? "start of birthyear" : "start of today")
// starfield
viewof star_in = Inputs.input(3)
viewof speed_in = Inputs.input(3)
viewof frame_in = Inputs.input(2)
viewof random_seed_in = Inputs.input("hello")
// loan bad. i_in problem?
viewof d_i_in = Inputs.input(0.02)
viewof d_i_year_in = Inputs.input(99)
viewof missed_repayment_year_in = Inputs.input(-99)
viewof skip_interest_in = Inputs.input(false)
viewof principal_in = Inputs.input(+(q.get('principal_in') ?? 100000))
viewof term_in = Inputs.input(+(q.get('term_in')??10))
// snowflakes
viewof height_in = Inputs.input(200)
viewof p_in = Inputs.input(1)
viewof w_in = Inputs.input(.6)
viewof width_in = Inputs.input(400)
viewof age_in = Inputs.input(25)
// savings-rec
viewof actual_interest_rate_co_in = Inputs.input(0)
mini_binds = {
return ({
fisheye_correction_in: Inputs.toggle({label:'🐟👀 correct'}),
duration_in: Inputs.range([0,20], {label:'duration', step: 1, disabled: modelname == 'savings_rec'}),
term_in: Inputs.select([25, 15, 10, 5, 30, 35, 40, 1, 480], {label: "Term (years)"}),
year_in: Inputs.range([-1,modelname == 'simple_loan' ? term_in : duration_in], {label:'year', step: 1}),
emissions_year_in: Inputs.range([1750,2024], {label:'emissions year', step: 1}),
age_in: Inputs.range([18,100], {label:'your age', step: 1}),
annual_payment_in: Inputs.range([0, 20000], {label:'annual_payment_in', step: 100, disabled: modelname == 'savings_rec'}),
interest_rate_in: Inputs.range([-0.1, 0.1], {format: d3.format('.3f'), label:'interest_rate_in', step:0.001, disabled: modelname == 'savings_rec'}) // precision how?
, actual_interest_rate_co_in: Inputs.range([-1, 20], {label:'actual_interest_rate_co_in', step:1})
, f_in: Inputs.range([0, 200], {label:'f_in', step:1})
, principal_in: Inputs.range([0, 500000], {label:'principal_in', step:1000})
//, keys_stream_function_in: md`(keys_stream_function_in)`
//, step_in: Tangle({min: -1, max: 20, label:'step_in'})
//, x_in: Tangle({min: -1, max: 200, label:'x_in'})
//, y_in: Tangle({min: -1, max: 200, label:'y_in'})
//, player_x_in: Tangle({min: -1, max: 10,format: d3.format('.2f'), label:'player_x_in'})
//, player_y_in: Tangle({min: -1, max: 10, format: d3.format('.2f'),label:'player_y_in'})
// off to check perf impact, ray_angle_in: Inputs.range([-20,20], {label:'ray_angle_in'})//Tangle({min: -1, max: 10, format: d3.format('.2f'),label:'ray_angle_in'})
, i_in: modelname == 'fizzbuzz' ? Inputs.range([-10, 200], {label:'i_in', step:1}) : Inputs.range([-0.1, 0.1], {label:'i_in', step:0.001})
, d_i_in: Inputs.range([-0.1, 0.1], {label:'Δ i_in', step:0.001})
, d_i_year_in: Inputs.range([-1,99], {label:'Δ i_in year', step: 1})
, step_in: Inputs.range([0, 10], {label:'step_in', step:1})
, date_in: Inputs.date({label: "date"})
, now_in: Inputs.date({label: "now"})
, timing_in: modelname == 'emissions_my_lifetime' ? Inputs.select(["start of birthyear", "end of birthyear"]) : Inputs.select(["start of today", "start of tomorrow"])
, random_seed_in: Inputs.text({label: 'random seed'})
, frame_in: Inputs.range([0,200], {label:'frame_in', step:1})
, star_in: Inputs.range([0,200], {label:'star_in', step:1})
, speed_in: Inputs.range([-1,10], {label:'speed_in', step:0.1})
})
}
Inputs.bind(mini_binds.fisheye_correction_in, viewof fisheye_correction_in)
Inputs.bind(mini_binds.duration_in, viewof duration_in)
Inputs.bind(mini_binds.year_in, viewof year_in)
Inputs.bind(mini_binds.emissions_year_in, viewof emissions_year_in)
Inputs.bind(mini_binds.annual_payment_in, viewof annual_payment_in)
Inputs.bind(mini_binds.interest_rate_in, viewof interest_rate_in)
Inputs.bind(mini_binds.actual_interest_rate_co_in, viewof actual_interest_rate_co_in)
Inputs.bind(mini_binds.f_in, viewof f_in)
Inputs.bind(mini_binds.x_in, viewof x_in)
Inputs.bind(mini_binds.y_in, viewof y_in)
Inputs.bind(mini_binds.player_x_in, viewof player_x_in)
Inputs.bind(mini_binds.player_y_in, viewof player_y_in)
Inputs.bind(mini_binds.step_in, viewof step_in)
Inputs.bind(mini_binds.ray_angle_in, viewof ray_angle_in)
Inputs.bind(mini_binds.i_in, viewof i_in)
Inputs.bind(mini_binds.date_in, viewof date_in)
Inputs.bind(mini_binds.timing_in, viewof timing_in)
Inputs.bind(mini_binds.random_seed_in, viewof random_seed_in)
Inputs.bind(mini_binds.frame_in, viewof frame_in)
Inputs.bind(mini_binds.speed_in, viewof speed_in)
Inputs.bind(mini_binds.star_in, viewof star_in)
Inputs.bind(mini_binds.principal_in, viewof principal_in)
Inputs.bind(mini_binds.term_in, viewof term_in)
Inputs.bind(mini_binds.age_in, viewof age_in)
Inputs.bind(mini_binds.d_i_in, viewof d_i_in)
Inputs.bind(mini_binds.d_i_year_in, viewof d_i_year_in)
Inputs.bind(mini_binds.now_in, viewof now_in)
// TODO MAKE STEPS HIGHLIGHT REACT TO STEP_IN TANGLE
```
```{ojs}
//| output: false
// working interactivity
html`<style>
.inputs {
padding: 20px;
}
button.btn {
background-color: antiquewhite;
color: blue;
padding:0;
}
.calculang {
line-height: 40px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
transition: all 0.2s linear;
}
div.calculang.cm-line:has(span.calculang_title) {
margin-top:20px;
}
.calculang.calculang_overwritten {
text-decoration: line-through;
font-weight: bold;
}
${formulae_hidden.length ? `.calculang {
background: #aaf3;
}` : ''}
${formulae_hidden.map(d => `.calculang_f_${d} + .calculang_f_${d}`).join(', ')} {
filter: blur(7px);
line-height: 5px;
opacity: 0.5;
} /* + selector to exclude first! https://coderwall.com/p/uugurw/css-selector-trick-select-all-elements-except-the-first */
${formulae_hidden.map(d => `.calculang_f_${d}`).join(', ')} {
opacity: 0.5;
background: white;
}${formulae_hidden.map(d => `.calculang_f_${d} .calculang_tooltip`).join(', ')} {
opacity: 0.1;
background: white;
}
${formulae_hidden.map(d => `.calculang_f_${d} > .calculang_title`).join(', ')} {
background-color: lightgreen;
font-size: 0.5em;
}
span.calculang_call {
white-space:nowrap;
cursor: zoom-in;
background-color: lightblue;
}
.tooltiptext {/* not all tooltiptexts go under a calculang call span! (single-length ones dont) */
/*color: red;*/
font-weight: bold;
}
.calculang_call.calculang_call_input {
/*cursor: none;*/
background-color: pink;
}
.calculang_call.calculang_call_input .tooltiptext {
color: #f53 !important;;
}
.calculang .calculang_title span {
padding: 3px;
background: #af54;
font-size: 1.5em;
font-weight: bold;
border: 1px solid grey;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.calculang_title.calculang_title_renamed {
text-decoration: line-through;
text-decoration-style: dashed;
}
</style>`
```
```{ojs}
//| output: false
//model = require(`${entrypoint_no_cul_js}.js`)//
/*models = ({savings: 3,//require(`${entrypoint_no_cul_js}.js`),
raycasting2: require('https://calculang.dev/models/raycasting/raycasting.js')})*/
// TODO work with memo savings-rec
fizzbuzz = await require(`https://calculang.dev/models/fizzbuzz/fizzbuzz.js`)
year_remaining = await require(`https://calculang.dev/models/year-remaining/year-remaining.js`)
starfield = await require(`https://calculang.dev/models/starfield/starfield.js`)
// UPDATE1 LOAD MODEL USING CORRECT REF
savings = await require(`https://calculang.dev/models/savings/savings.js`);
savings_rec = await require(`https://calculang.dev/models/savings/savings-rec.js`)
introspection_fetch = await fetch(`${entrypoint_no_cul_js}.introspection.json`)
introspection = await introspection_fetch.json({typed:true})
introspection_nomemo_fetch = await fetch(`${entrypoint_no_cul_js}${calculang_source_nomemo.length ? '-nomemo' : ''}.introspection.json`)
introspection_nomemo = await introspection_nomemo_fetch.json({typed:true})
calculang_source_introspection = calculang_source_nomemo.length ? introspection_nomemo : introspection
formulae_objs = Object.values(calculang_source_introspection.cul_functions).filter(d => d.reason == 'definition' && inputs.indexOf(d.name+'_in') == -1)
input_formulae_objs = Object.values(calculang_source_introspection.cul_functions).filter(d => d.reason == 'definition' && inputs.indexOf(d.name+'_in') != -1)
inputs = _.uniq(Object.values(calculang_source_introspection.cul_functions).filter(d => d.reason == 'input definition').map(d => d.name).sort())
fns0 = Object.values(calculang_source_introspection.cul_functions).filter(d => d.cul_scope_id == 0).map(d => d.inputs).flat()
import { CodeMirror, loadCodeMirrorModules } from "@jmatsushita/codemirror@670";
cmImports = loadCodeMirrorModules([
"view@6.22.2", // chk versions?
"state@6.3.3",
"language@6.9.3",
"lang-javascript"
//"commands@6.3.2",
]);
EditorView = cmImports.view.EditorView
EditorState = cmImports.state.EditorState
Decoration = cmImports.view.Decoration
set = (input, value) => {
input.value = value;
input.dispatchEvent(new Event("input", {bubbles: true}));
}
//////////// plugin 1: decoration & cul navigation for function-level
syntaxTree = cmImports.language.syntaxTree
formulaDecorations = {
return (options) => {
//set(options.formulae_visible, [""]) // this was doing a lot of jank!!
const formulaDecorations = cmImports.view.ViewPlugin.fromClass(
class {
constructor(view) {
this.decorations = formulaDecoration(view);
}
update(update) {
if (update.docChanged || update.viewportChanged)
this.decorations = formulaDecoration(update.view);
}
},
{
decorations: (v) => v.decorations,
eventHandlers: {
mousedown: (e, view) => { // HMMM I'll need to resolve that calls get precedence!!! Should be working:
let classList = [...e.target.classList, ...e.target.parentElement.classList] // very open, be aware of bugs ?!
if (e.target.classList.contains("cul_call")) // TODO
1;//set(viewof formulae_shown, [target.textContent]); TODO
else if (
//e.target.classList.contains("deposits") ||
//e.target.parentElement.classList.contains("deposits")
classList.filter(d => d.includes("calculang_f_")).length
)
set(options.formulae_visible, [classList.find(d => d.includes("calculang_f_")).slice("calculang_f_".length)]);
/////// causes unnecessary jitter when we already see f document.querySelector('.'+classList.find(d => d.includes("calculang_f_"))).scrollIntoView(scrollIntoViewOpts)
//trying it
document.querySelector('.'+classList.find(d => d.includes("calculang_f_"))).scrollIntoView(scrollIntoViewOpts)
}
}
}
);
return [formulaDecorations];
}
}
// Decoration.lines
formulaDecoration = (view) => Decoration.set(
formula_line_details
.map((d) =>
_.range(d.lineStart, d.lineEnd + 0.1).map((e) =>
Decoration.line({
attributes: {
class: "calculang" + " " + "calculang_f_"+d.name + (d.overwritten ? ' calculang_overwritten' : '') /* +style available */ // leaving scope and other potential conflicts out
}
}).range(view.state.doc.line(e).from)
)
)
.flat())
formula_line_details = Object.values(calculang_source_introspection.cul_functions)
.filter((d) => d.reason.includes("definition") && d.name.slice(-3) != '_in' && d.cul_scope_id == cul_scope_id)
.map(({ name, loc, reason }) => ({
name,
lineStart: loc?.start.line,
lineEnd: loc?.end.line,
overwritten: name.slice(-1) == '_' && !(Object.values(calculang_source_introspection.cul_functions).filter(d => d.imported == name && d.cul_source_scope_id == cul_scope_id)).length // and not explicit imported/used in parent defn
}))
formula_line_details_0 = Object.values(calculang_source_introspection.cul_functions)
.filter((d) => d.reason.includes("definition") && d.name.slice(-3) != '_in' && d.cul_scope_id == 0)
.map(({ name, loc, reason }) => ({
name,
lineStart: loc?.start.line,
lineEnd: loc?.end.line,
overwritten: name.slice(-1) == '_' && !(Object.values(calculang_source_introspection.cul_functions).filter(d => d.imported == name)).length // and not explicit imported/used in parent defn
}))
//////////// plugin 2: decoration & cul navigation for call-level, also decoration for titles. By syntax tree analysis
// uses formulae_all, inputs: should derive from entrypoint/introspection before splitting up
// also sets formae_visible
// inconsistent naming !
formulae_hidden = formulae_all.filter((d) => !formulae_visible.includes(d))
formulae_all = formula_line_details.map((d) => d.name) // poor?
viewof hover = Inputs.text("")
{
console.log('eee', hover)
if (hover == 'rv_hit_distance') {
set(viewof show_ray_v, true)
set(viewof show_ray_h, false)
}
if (hover == 'rh_hit_distance') {
set(viewof show_ray_v, false)
set(viewof show_ray_h, true)
}
}
//inputs = _.uniq(Object.values(introspection.cul_input_map).flat())
calculang_identifier_decorations = {
return (options) => {
//set(options.formulae_visible, formulae_all) // WHERE DOES THIS NEED TO GO?
const decorations = cmImports.view.ViewPlugin.fromClass(
class {
constructor(view) {
this.decorations = identifier_decorations(view);
}
update(update) {
//debugger; this is called a LOT!!
//if (update.docChanged || update.focusChanged|| update.viewportChanged || update.geometryChanged || update.heightChanged) // expensive things on scroll, but didn't run on full doc for some reason?!
this.decorations = identifier_decorations(update.view);
// why
}
},
{
decorations: (v) => v.decorations,
eventHandlers: {
mousemove: (e, view) => {
let classList = [...e.target.classList, ...e.target.parentElement.classList] // very open, be aware of bugs ?!
let c = classList.filter(d => d.includes("calculang_call_"))
let cc= 'badvalue';
if (c.length) cc = c[0].slice("calculang_call_".length)
if (e.target.classList.contains("calculang_call") || classList.includes("calculang_title")) { // TODO only if the containing formula is visible, I have options.formulae_visible:
//console.log('HIHIHIEE')
//debugger;
set(viewof hover, cc) // too many triggers !
}
},
mousedown: (e, view) => {
let classList = [...e.target.classList, ...e.target.parentElement.classList] // very open, be aware of bugs ?!
let c = classList.filter(d => d.includes("calculang_call_") && d != "calculang_call_input")
let cc= 'badvalue';
if (c.length) cc = c[0].slice("calculang_call_".length)
if (e.target.classList.contains("calculang_call") || classList.includes("calculang_title")) { // TODO only if the containing formula is visible, I have options.formulae_visible:
//console.log('HIHIHIEE')
//debugger;
set(options.formulae_visible, [cc])
document.querySelector('.calculang_f_'+cc).scrollIntoView(scrollIntoViewOpts)
}
else if (
//e.target.classList.contains("deposits") ||
//e.target.parentElement.classList.contains("deposits")
classList.filter(d => d.includes("calculang_f_")).length
) { // this is setting when you click in the area of a formula - no need to scroll
set(options.formulae_visible, [classList.find(d => d.includes("calculang_f_")).slice("calculang_f_".length)]);
//document.querySelector('.'+classList.find(d => d.includes("calculang_f_"))).scrollIntoView(scrollIntoViewOpts)
}
}
}
}
);
return [decorations];
}
}
// Decoration.marks specified by ranges
identifier_decorations = view => {
let decorations = [];
//for (let { from, to } of view.visibleRanges) {
console.log(view.state)
console.log(view.visibleRanges)
//for (let { from, to } of [{from: 0, to: 1000}]) {
//debugger;
//debugger;
for (let { from, to } of view.visibleRanges) {
//for (let { from, to } of [{from:0, to:5000}]) {
//cmImports.language.syntaxTreeAvailable(view.state, )
//cmImports.language.forceParsing(view, )
cmImports.language.syntaxTree(view.state).iterate({
from,
to,
enter: (node) => {
if (node.name == "VariableDefinition") {
let name = view.state.doc.sliceString(node.from, node.to);
if (formulae_all.includes(name)) {
decorations.push(
Decoration.mark({ class: "calculang_title" }).range(
node.from,
node.to
)
);
}
if (formulae_all.includes(name + '_')) {
decorations.push(
Decoration.mark({ class: "calculang_title calculang_title_renamed" }).range(
node.from,
node.to
)
);
}
}
if (node.name == "VariableName") {
let name = view.state.doc.sliceString(node.from, node.to);
if (formulae_all.includes(name)) {
if (inputs.includes(name + "_in"))
decorations.push(
Decoration.mark({ class: `calculang_call calculang_call_input calculang_call_${name}` }).range(
node.from,
node.to
)
);
else
decorations.push(
Decoration.mark({ class: `calculang_call calculang_call_${name}` }).range(node.from, node.to)
);
}
}
}
});
}
return Decoration.set(decorations);
}
```
<!--## Row {height=50%}-->
## Col
<!--## formulas 🕵🏼♀️ {width=800px}-->
::: {.fill #left}
:::: {.fill}
::::
<style>
.card:has(#left) {
background-color: #69ff6111;
}
#left {
/*background-color: ;*/
border: 0;
}
#left * .card-body {
background-color: white;
padding: 0;
border: 0;
}
#left .observablehq {
background-color: white;
}
.card:has(.modeldept) {
background-color: #D81B6011;
}
</style>
<!-- hassle for modularity => tabs (so pretty in Quarto) need to become select box or buttons. Style later -->
```{ojs}
//| output: false
viewof x = Inputs.input(0)
formulae_visible
formulae_all
inputs
formulae_hidden
md`---`
//////////////// code for getting source
examples_yaml = await (await fetch('/gallery.yml')).text()
yaml = require('js-yaml@4.1.0/dist/js-yaml.min.js')
examples = yaml.load(examples_yaml)
selected_model = Generators.input(a_thing2)
example_details = examples.map(d => d.tiles).flat().find(d => d.id == selected_model)
modelname = example_details.id.replaceAll('-','_') // replace due to object lookups
q = new URLSearchParams(location.search)
default_example_id = q.get('id') ?? ''
show_hidden = true// q.get('hidden') == 'hidden' ?? true
dir = dirname(example_entrypoint)
//https://www.abeautifulsite.net/posts/javascript-functions-for-basename-and-dirname/
function dirname(path) {
return path.match(/.*\//);
}
example_entrypoint = entrypoint
entrypoint = (example_details.entrypoint[0] == "/" ? "https://calculang.dev" : "") +
example_details.entrypoint
entrypoint_no_cul_js = entrypoint.slice(0,-7)
//viewof entrypoint = Inputs.select(new Map(entrypoints_all.map((d,i) => [d[1],i])), {label:'model 👀', value:1}) // leaving on simple-climate as it breaks if not default :o
// hacky, do qs parsing?
// I should view .mjs instead of .cul.js for memo case?
cul_resources = {
if (cul_js_cul)
return Object.values(introspection_nomemo.cul_scope_ids_to_resource).map(loc => loc.slice(2).slice(0,loc.indexOf('?') != -1 ? loc.indexOf('?')-2 : 999)).map(d => d + ((d.slice(-3) != '.js') ? '.js' : '')).map(loc => dir+ loc)
else return [...Array(Object.keys(introspection_nomemo.cul_scope_ids_to_resource).length)].map((_, i) => entrypoint_no_cul_js /* this is not modelname! this should be related to entrypoit, not id */+(calculang_source_nomemo.length? '-nomemo' : '') +'_esm/'+'cul_scope_'+i+'.mjs')
}
//cul_resources
output = {
let o = [];
cul_resources.forEach(loc => {
o.push(fetch(loc).then(d => d.text()))
})
return o
}
// TODO replace duplicate (source) code by a message
calculang = [await output[0], cul_resources.length > 1 ? await output[1] : ''
, cul_resources.length > 2 ? await output[2] : ''
, cul_resources.length > 3 ? await output[3] : ''
, cul_resources.length > 4 ? await output[4] : ''
, cul_resources.length > 5 ? await output[5] : ''
, cul_resources.length > 6 ? await output[6] : '' // TODO warn when overflows
, cul_resources.length > 7 ? await output[7] : ''].filter(d => d != '')
//calculang
// "x.cul.js formulae?"
fff = calculang.map(d => d.split('\n')).map(d => [d.findIndex(e => e.indexOf('inputs:' + (options.includes('inputs') ? 'BLAH' : '')) != -1) ?? 999, ...d]).map(d => d.filter((e,i) => i <= d[0] || d[0] == -1)).map(d => d.slice(1)).map(d => d.join('\n')).map((d,i) => `***[${introspection.cul_scope_ids_to_resource[i].split('?')[0].replaceAll('-nomemo', '')}](${cul_resources[i].replaceAll('-nomemo','')}) ${cul_js_cul ? `-> [js](${entrypoint_no_cul_js}_esm/cul_scope_${i}.mjs)` : ``}***
~~~js
${d.replaceAll('export const ' + (options.includes('export consts')
? 'BLAH' : ''), '')}
~~~
`
)
fff2 = calculang.filter((d,i) => i == cul_scope_id).map(d => d.split('\n')).map(d => [d.findIndex(e => e.indexOf('inputs:' + (options.includes('inputs') ? 'BLAH' : '')) != -1) ?? 999, ...d]).map(d => d.filter((e,i) => i <= d[0] || d[0] == -1)).map(d => d.slice(1)).map(d => d.join('\n'))
.map((d,i) => `${d.replaceAll('export const ' + (options.includes('export consts')
? 'BLAH' : ''), '')}`
)
fff
```
<style>
#fdsa {
background-color: lightgreen;
padding: 10px;
margin-bottom:20px;
border-radius: 0 20px 20px 20px;
min-height: fit-content;
}
</style>
:::: {#fdsa}
![](./logo4.svg){width=40} <strong style="font-size:1.5em;">calculang model</strong>
```{ojs}
//md`${fff.join('\n\n')}`
enabled = ["raycasting2", "savings", "savings_rec", "starfield", "fizzbuzz", "year_remaining", "simple_loan"/*, "emissions_my_lifetime"*/]
a_thing2 = html`<select style="font-size: 1.5em">
${examples.map(category => `<optgroup label="${category.category}">
${category.tiles.filter(tile => ((!tile.disabled) || show_hidden)).filter(d => enabled.includes(d.id.replaceAll('-','_'))).map(d => `<option value="${d.id}"${d.id == default_example_id ? ' selected="selected"' : ''}}>${d.title}</option>`)}
${category.tiles.filter(d => d.id == default_example_id && d.disabled && (!show_hidden)).map(d => `<option value="${d.id}"${d.id == default_example_id ? ' selected="selected"' : ''}}>${d.title}</option>`)}
</optgroup>
`)}</select>`
md`${example_details.modular ? '♻️' : ''} *${example_details.subtitle}*`
viewof cul_scope_id = Inputs.range([0,15], {label: 'cul scope id', value:0, step:1})
viewof form = Inputs.form(mini_binds, {
template: inputs2 => htl.html`<details id="inputs_details" open><summary>inputs ⚙️</summary><div class="styled">${Object.entries(inputs2)/*.filter(([k,v]) => inputs.includes(k))*/.map(([k,v]) => htl.html`<div id="mini-bind-${k}" class="mini-bind">${v}`)}`
//template: inputs2 => htl.html`${Object.entries(inputs2)/*.filter(([k,v]) => inputs.includes(k))*/.map(([k,v]) => htl.html`<div id="mini-bind-${k}" class="mini-bind styled">${v}`)}`
})
html`
<style>
#inputs_details {
background: #66ddc155;
margin-bottom:0;
}
div.styled {
text-align: right;
column-count: 2;
}
div.styled {
font-weight: bold;
font-size: 0.7em;
}
div.styled label {
/*width: 50px !important;*/
}
div.styled label:not(div>label):after {
content: ":";
}
div.mini-bind {
display:none;
}
${inputs.map(d => `div#mini-bind-${d} {
display: block;
}`).join('\n\n')}
</style>
`
/*{
year_in;
viewof form.value.year_in = year_in;
viewof form.dispatchEvent(new Event("input", {bubbles: true}));
}*/
//, template: inputs => htl.html`<details open>
// ${Object.values(inputs)/*.filter(([k,v]) => inputs.includes(k))*//*.map(([k,v]) => v)*/}
//</details>`) // https://observablehq.com/@martien/horizontal-inputs
// still not reliable, do set implementation?
```
::::
<!-- details here is nice to collapse the editor, but alters layout when open -->
```{ojs}
show = _.uniq(Object.values(calculang_source_introspection.cul_functions).filter(d => d.reason == 'input definition').map(d => d.name).sort()).filter(d => formula_line_details_0.filter(e => e.name + '_in' == d && (e.overwritten == undefined || e.overwritten == false)).length)
st = {
entrypoint_no_cul_js;
// I cannot fetch !!!
//fetch(`${entrypoint_no_cul_js}${1 ? '-nomemo' : ''}.introspection.json`);
//await introspection_nomemo; // I can depend on modelname but NOT inputs or introspection !
return ['year_in', 'duration_in', 'f_in'] // "annual_payment_in", "duration_in", "interest_rate_in", "year_in"
// not working
}
//fff2.join('\n\n')
/*mjs_q_eval
aa
model*/
viewof editor = CodeMirror(
// This needs to be entrypoint scopeid?
fff2.join('\n\n'),
{
extensions: [ // wrap indicators would be nice
// myDefaultTheme, // TODO bring this in, + dark version
cmImports["lang-javascript"].javascript(),
//cmImports["language"].foldGutter(),
//EditorView.decorations.of(Decoration.set(yellow.range(r)))
/* BUILDING cmCheckboxPluginViewof, // does cul code annotation and navigation, depending on showStripes
cmOverlayPluginViewof,*/
overlay ? overlay_answers : EditorState.readOnly.of(true),
overlay ? overlay_workings : EditorState.readOnly.of(true),
formulaDecorations({formulae_visible: viewof formulae_visible}), // https://codemirror.net/examples/zebra/
/* TODO don't process Import/Exports for now */ calculang_identifier_decorations({formulae_visible: viewof formulae_visible}),
EditorView.lineWrapping,
EditorView.editable.of(true),
EditorState.readOnly.of(true)
]
}
)
```
```{ojs}
//| output: false
///////////// overlay plugin:
//// evals; from generator in reactive-workings
interest_rate_expected = () => 0 // still needed, TODO fix!
//interest_rate_expected = () => 0
///// COPY EVALS
mjs_q_eval = { return ({"raycasting2":[[{name: "ray_angle", value:raycasting2.ray_angle({ ray_angle_in })},{name: "tan_ray_angle", value:raycasting2.tan_ray_angle({ ray_angle_in })},{name: "ray_angle", value:raycasting2.ray_angle({ ray_angle_in })},{name: "ray_angle", value:raycasting2.ray_angle({ ray_angle_in })},{name: "y", value:raycasting2.y({ y_in })},{name: "x", value:raycasting2.x({ x_in })},{name: "x", value:raycasting2.x({ x_in })},{name: "y", value:raycasting2.y({ y_in })},{name: "map", value:raycasting2.map({})},{name: "y", value:raycasting2.y({ y_in })},{name: "x", value:raycasting2.x({ x_in })},{name: "map", value:raycasting2.map({})},{name: "y", value:raycasting2.y({ y_in })},{name: "x", value:raycasting2.x({ x_in })},{name: "step", value:raycasting2.step({ step_in })},{name: "player_x", value:raycasting2.player_x({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "player_y", value:raycasting2.player_y({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rhy", value:raycasting2.rhy({ ray_angle_in, step_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "inverse_tan_ray_angle", value:raycasting2.inverse_tan_ray_angle({ ray_angle_in })},{name: "rhx", value:raycasting2.rhx({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in, step_in:raycasting2.step({ step_in }) - 1 }), handler: () => {set(viewof step_in, raycasting2.step({ step_in }) - 1)}},{name: "step", value:raycasting2.step({ step_in })},{name: "ray_looking_up", value:raycasting2.ray_looking_up({ ray_angle_in })},{name: "inverse_tan_ray_angle", value:raycasting2.inverse_tan_ray_angle({ ray_angle_in })},{name: "ray_looking_up", value:raycasting2.ray_looking_up({ ray_angle_in })},{name: "step", value:raycasting2.step({ step_in })},{name: "player_y", value:raycasting2.player_y({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rhy", value:raycasting2.rhy({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, step_in:raycasting2.step({ step_in }) - 1 }), handler: () => {set(viewof step_in, raycasting2.step({ step_in }) - 1)}},{name: "step", value:raycasting2.step({ step_in })},{name: "step", value:raycasting2.step({ step_in })},{name: "player_y", value:raycasting2.player_y({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rhy", value:raycasting2.rhy({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, step_in:raycasting2.step({ step_in }) - 1 }), handler: () => {set(viewof step_in, raycasting2.step({ step_in }) - 1)}},{name: "step", value:raycasting2.step({ step_in })},{name: "map_lookup", value:raycasting2.map_lookup({ x_in:raycasting2.rhx({ step_in, f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in }), y_in:raycasting2.rhy({ ray_angle_in, step_in, f_in, keys_stream_version_in, keys_stream_function_in }) }), handler: () => {set(viewof x_in, raycasting2.rhx({ step_in, f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })); set(viewof y_in, raycasting2.rhy({ ray_angle_in, step_in, f_in, keys_stream_version_in, keys_stream_function_in }))}},{name: "rhx", value:raycasting2.rhx({ step_in, f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "rhy", value:raycasting2.rhy({ ray_angle_in, step_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rhv", value:raycasting2.rhv({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in, step_in })},{name: "rhx", value:raycasting2.rhx({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in, step_in })},{name: "rhy", value:raycasting2.rhy({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, step_in })},{name: "rhv", value:raycasting2.rhv({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in, step_in })},{name: "rh_hit_object", value:raycasting2.rh_hit_object({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "rh_hit_object", value:raycasting2.rh_hit_object({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "rh_hit_object", value:raycasting2.rh_hit_object({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "rh_hit_object", value:raycasting2.rh_hit_object({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "rh_hit_x", value:raycasting2.rh_hit_x({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "player_x", value:raycasting2.player_x({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rh_hit_y", value:raycasting2.rh_hit_y({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "player_y", value:raycasting2.player_y({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "ray_looking_right", value:raycasting2.ray_looking_right({ ray_angle_in })},{name: "step", value:raycasting2.step({ step_in })},{name: "player_x", value:raycasting2.player_x({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rvx", value:raycasting2.rvx({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, step_in:raycasting2.step({ step_in }) - 1 }), handler: () => {set(viewof step_in, raycasting2.step({ step_in }) - 1)}},{name: "step", value:raycasting2.step({ step_in })},{name: "step", value:raycasting2.step({ step_in })},{name: "player_x", value:raycasting2.player_x({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rvx", value:raycasting2.rvx({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, step_in:raycasting2.step({ step_in }) - 1 }), handler: () => {set(viewof step_in, raycasting2.step({ step_in }) - 1)}},{name: "step", value:raycasting2.step({ step_in })},{name: "step", value:raycasting2.step({ step_in })},{name: "player_y", value:raycasting2.player_y({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "player_x", value:raycasting2.player_x({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rvx", value:raycasting2.rvx({ ray_angle_in, step_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "tan_ray_angle", value:raycasting2.tan_ray_angle({ ray_angle_in })},{name: "rvy", value:raycasting2.rvy({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in, step_in:raycasting2.step({ step_in }) - 1 }), handler: () => {set(viewof step_in, raycasting2.step({ step_in }) - 1)}},{name: "step", value:raycasting2.step({ step_in })},{name: "ray_looking_right", value:raycasting2.ray_looking_right({ ray_angle_in })},{name: "tan_ray_angle", value:raycasting2.tan_ray_angle({ ray_angle_in })},{name: "map_lookup", value:raycasting2.map_lookup({ x_in:raycasting2.rvx({ ray_angle_in, step_in, f_in, keys_stream_version_in, keys_stream_function_in }), y_in:raycasting2.rvy({ step_in, f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in }) }), handler: () => {set(viewof x_in, raycasting2.rvx({ ray_angle_in, step_in, f_in, keys_stream_version_in, keys_stream_function_in })); set(viewof y_in, raycasting2.rvy({ step_in, f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in }))}},{name: "rvx", value:raycasting2.rvx({ ray_angle_in, step_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rvy", value:raycasting2.rvy({ step_in, f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "rvv", value:raycasting2.rvv({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, step_in })},{name: "rvx", value:raycasting2.rvx({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, step_in })},{name: "rvy", value:raycasting2.rvy({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in, step_in })},{name: "rvv", value:raycasting2.rvv({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, step_in })},{name: "rv_hit_object", value:raycasting2.rv_hit_object({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rv_hit_object", value:raycasting2.rv_hit_object({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rv_hit_object", value:raycasting2.rv_hit_object({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rv_hit_object", value:raycasting2.rv_hit_object({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rv_hit_x", value:raycasting2.rv_hit_x({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "player_x", value:raycasting2.player_x({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rv_hit_y", value:raycasting2.rv_hit_y({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "player_y", value:raycasting2.player_y({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rv_hit_distance", value:raycasting2.rv_hit_distance({ y_in, x_in, ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rh_hit_distance", value:raycasting2.rh_hit_distance({ y_in, x_in, f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "r_hit_h_or_v", value:raycasting2.r_hit_h_or_v({ y_in, x_in, ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rv_hit_object", value:raycasting2.rv_hit_object({ ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rh_hit_object", value:raycasting2.rh_hit_object({ f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "r_hit_object", value:raycasting2.r_hit_object({ y_in, x_in, ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "r_hit_object", value:raycasting2.r_hit_object({ y_in, x_in, ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "r_hit_object", value:raycasting2.r_hit_object({ y_in, x_in, ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "r_hit_object", value:raycasting2.r_hit_object({ y_in, x_in, ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rv_hit_distance", value:raycasting2.rv_hit_distance({ y_in, x_in, ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in })},{name: "rh_hit_distance", value:raycasting2.rh_hit_distance({ y_in, x_in, f_in, keys_stream_version_in, keys_stream_function_in, ray_angle_in })},{name: "fisheye_correction", value:raycasting2.fisheye_correction({ fisheye_correction_in })},{name: "player_angle", value:raycasting2.player_angle({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "ray_angle", value:raycasting2.ray_angle({ ray_angle_in })},{name: "ray_distance", value:raycasting2.ray_distance({ y_in, x_in, ray_angle_in, f_in, keys_stream_version_in, keys_stream_function_in, fisheye_correction_in })},{name: "keys_stream_version", value:raycasting2.keys_stream_version({ keys_stream_version_in })},{name: "keys_stream_function", value:raycasting2.keys_stream_function({ keys_stream_function_in })},{name: "f", value:raycasting2.f({ f_in })},{name: "keys", value:raycasting2.keys({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "keys", value:raycasting2.keys({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "keys", value:raycasting2.keys({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "keys", value:raycasting2.keys({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "keys", value:raycasting2.keys({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "keys", value:raycasting2.keys({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "keys", value:raycasting2.keys({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "keys", value:raycasting2.keys({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "key_up", value:raycasting2.key_up({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "key_down", value:raycasting2.key_down({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "key_left", value:raycasting2.key_left({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "key_right", value:raycasting2.key_right({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "f", value:raycasting2.f({ f_in })},{name: "player_angle", value:raycasting2.player_angle({ keys_stream_version_in, keys_stream_function_in, f_in:raycasting2.f({ f_in }) - 1 }), handler: () => {set(viewof f_in, raycasting2.f({ f_in }) - 1)}},{name: "f", value:raycasting2.f({ f_in })},{name: "leftness", value:raycasting2.leftness({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "f", value:raycasting2.f({ f_in })},{name: "player_x", value:raycasting2.player_x({ keys_stream_version_in, keys_stream_function_in, f_in:raycasting2.f({ f_in }) - 1 }), handler: () => {set(viewof f_in, raycasting2.f({ f_in }) - 1)}},{name: "f", value:raycasting2.f({ f_in })},{name: "forwardness", value:raycasting2.forwardness({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "speed", value:raycasting2.speed({})},{name: "player_angle", value:raycasting2.player_angle({ f_in, keys_stream_version_in, keys_stream_function_in })},{name: "f", value:raycasting2.f({ f_in })},{name: "player_y", value:raycasting2.player_y({ keys_stream_version_in, keys_stream_function_in, f_in:raycasting2.f({ f_in }) - 1 }), handler: () => {set(viewof f_in, raycasting2.f({ f_in }) - 1)}},{name: "f", value:raycasting2.f({ f_in })},{name: "forwardness", value:raycasting2.forwardness({ keys_stream_version_in, keys_stream_function_in, f_in })},{name: "speed", value:raycasting2.speed({})},{name: "player_angle", value:raycasting2.player_angle({ f_in, keys_stream_version_in, keys_stream_function_in })}]],"savings":[[{name: "year", value:savings.year({ year_in })},{name: "year", value:savings.year({ year_in })},{name: "deposits", value:savings.deposits({ year_in, duration_in, annual_payment_in })},{name: "balance", value:savings.balance({ duration_in, annual_payment_in, interest_rate_in, year_in:savings.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, savings.year({ year_in }) - 1)}},{name: "year", value:savings.year({ year_in })},{name: "deposits", value:savings.deposits({ year_in, duration_in, annual_payment_in })},{name: "interest", value:savings.interest({ year_in, duration_in, annual_payment_in, interest_rate_in })},{name: "year", value:savings.year({ year_in })},{name: "year", value:savings.year({ year_in })},{name: "duration", value:savings.duration({ duration_in })},{name: "annual_payment", value:savings.annual_payment({ annual_payment_in })},{name: "year", value:savings.year({ year_in })},{name: "balance", value:savings.balance({ duration_in, annual_payment_in, interest_rate_in, year_in:savings.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, savings.year({ year_in }) - 1)}},{name: "year", value:savings.year({ year_in })},{name: "interest_rate", value:savings.interest_rate({ interest_rate_in })}]],"savings_rec":[[{name: "year", value:savings_rec.year({ year_in })},{name: "actual_interest_rate_co", value:savings_rec.actual_interest_rate_co({ actual_interest_rate_co_in })},{name: "interest_rate_expected", value:interest_rate_expected({})},{name: "actual_interest_rates", value:savings_rec.actual_interest_rates({})},{name: "year", value:savings_rec.year({ year_in })}],[],[{name: "year", value:savings_rec.year({ year_in })},{name: "year", value:savings_rec.year({ year_in })},{name: "deposits", value:savings_rec.deposits({ year_in })},{name: "balance", value:savings_rec.balance({ actual_interest_rate_co_in, year_in:savings_rec.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, savings_rec.year({ year_in }) - 1)}},{name: "year", value:savings_rec.year({ year_in })},{name: "deposits", value:savings_rec.deposits({ year_in })},{name: "interest", value:savings_rec.interest({ year_in, actual_interest_rate_co_in })},{name: "year", value:savings_rec.year({ year_in })},{name: "year", value:savings_rec.year({ year_in })},{name: "duration", value:savings_rec.duration({})},{name: "annual_payment", value:savings_rec.annual_payment({})},{name: "year", value:savings_rec.year({ year_in })},{name: "balance", value:savings_rec.balance({ actual_interest_rate_co_in, year_in:savings_rec.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, savings_rec.year({ year_in }) - 1)}},{name: "year", value:savings_rec.year({ year_in })},{name: "interest_rate", value:savings_rec.interest_rate({ year_in, actual_interest_rate_co_in })}]],"starfield":[[{name: "random_seed", value:starfield.random_seed({ random_seed_in })},{name: "seeded", value:starfield.seeded({ random_seed_in:starfield.random_seed({ random_seed_in }) }), handler: () => {set(viewof random_seed_in, starfield.random_seed({ random_seed_in }))}},{name: "random_seed", value:starfield.random_seed({ random_seed_in })},{name: "random", value:starfield.random({ random_seed_in, star_in:starfield.star({ star_in }), id: "x" }), handler: () => {set(viewof star_in, starfield.star({ star_in }))}},{name: "star", value:starfield.star({ star_in })},{name: "random", value:starfield.random({ random_seed_in, star_in:starfield.star({ star_in }), id: "y" }), handler: () => {set(viewof star_in, starfield.star({ star_in }))}},{name: "star", value:starfield.star({ star_in })},{name: "random", value:starfield.random({ random_seed_in, star_in:starfield.star({ star_in }), id: "z" }), handler: () => {set(viewof star_in, starfield.star({ star_in }))}},{name: "star", value:starfield.star({ star_in })},{name: "frame", value:starfield.frame({ frame_in })},{name: "z0", value:starfield.z0({ random_seed_in, star_in })},{name: "z", value:starfield.z({ random_seed_in, star_in, speed_in, frame_in:starfield.frame({ frame_in }) - 1 }), handler: () => {set(viewof frame_in, starfield.frame({ frame_in }) - 1)}},{name: "frame", value:starfield.frame({ frame_in })},{name: "speed", value:starfield.speed({ speed_in })},{name: "z", value:starfield.z({ random_seed_in, star_in, speed_in, frame_in:starfield.frame({ frame_in }) - 1 }), handler: () => {set(viewof frame_in, starfield.frame({ frame_in }) - 1)}},{name: "frame", value:starfield.frame({ frame_in })},{name: "speed", value:starfield.speed({ speed_in })},{name: "z", value:starfield.z({ frame_in, random_seed_in, star_in, speed_in })},{name: "frame", value:starfield.frame({ frame_in })},{name: "x0", value:starfield.x0({ random_seed_in, star_in })},{name: "visible", value:starfield.visible({ random_seed_in, star_in, speed_in, frame_in:starfield.frame({ frame_in }) - 1 }), handler: () => {set(viewof frame_in, starfield.frame({ frame_in }) - 1)}},{name: "frame", value:starfield.frame({ frame_in })},{name: "x0", value:starfield.x0({ random_seed_in, star_in })},{name: "x0", value:starfield.x0({ random_seed_in, star_in })},{name: "z", value:starfield.z({ frame_in, random_seed_in, star_in, speed_in })},{name: "frame", value:starfield.frame({ frame_in })},{name: "y0", value:starfield.y0({ random_seed_in, star_in })},{name: "visible", value:starfield.visible({ random_seed_in, star_in, speed_in, frame_in:starfield.frame({ frame_in }) - 1 }), handler: () => {set(viewof frame_in, starfield.frame({ frame_in }) - 1)}},{name: "frame", value:starfield.frame({ frame_in })},{name: "y0", value:starfield.y0({ random_seed_in, star_in })},{name: "y0", value:starfield.y0({ random_seed_in, star_in })},{name: "z", value:starfield.z({ frame_in, random_seed_in, star_in, speed_in })},{name: "x", value:starfield.x({ frame_in, random_seed_in, star_in, speed_in })},{name: "x0", value:starfield.x0({ random_seed_in, star_in })},{name: "x0", value:starfield.x0({ random_seed_in, star_in })},{name: "x", value:starfield.x({ random_seed_in, star_in, speed_in, frame_in:starfield.frame({ frame_in }) - 1 }), handler: () => {set(viewof frame_in, starfield.frame({ frame_in }) - 1)}},{name: "frame", value:starfield.frame({ frame_in })},{name: "y", value:starfield.y({ frame_in, random_seed_in, star_in, speed_in })},{name: "y0", value:starfield.y0({ random_seed_in, star_in })},{name: "y0", value:starfield.y0({ random_seed_in, star_in })},{name: "y", value:starfield.y({ random_seed_in, star_in, speed_in, frame_in:starfield.frame({ frame_in }) - 1 }), handler: () => {set(viewof frame_in, starfield.frame({ frame_in }) - 1)}},{name: "frame", value:starfield.frame({ frame_in })}]],"fizzbuzz":[[{name: "i", value:fizzbuzz.i({ i_in })},{name: "i", value:fizzbuzz.i({ i_in })},{name: "fizz", value:fizzbuzz.fizz({ i_in })},{name: "buzz", value:fizzbuzz.buzz({ i_in })},{name: "fizz", value:fizzbuzz.fizz({ i_in })},{name: "buzz", value:fizzbuzz.buzz({ i_in })},{name: "i", value:fizzbuzz.i({ i_in })}]],"year_remaining":[[{name: "date", value:year_remaining.date({ date_in })},{name: "year", value:year_remaining.year({ date_in })},{name: "isLeap", value:year_remaining.isLeap({ date_in })},{name: "date", value:year_remaining.date({ date_in })},{name: "date", value:year_remaining.date({ date_in })},{name: "date", value:year_remaining.date({ date_in })},{name: "date", value:year_remaining.date({ date_in })},{name: "daysIntoYearStartTomorrow", value:year_remaining.daysIntoYearStartTomorrow({ date_in })},{name: "timing", value:year_remaining.timing({ timing_in })},{name: "daysIntoYearStartToday", value:year_remaining.daysIntoYearStartToday({ date_in })},{name: "daysIntoYearStartTomorrow", value:year_remaining.daysIntoYearStartTomorrow({ date_in })},{name: "daysIntoYear", value:year_remaining.daysIntoYear({ timing_in, date_in })},{name: "daysInYear", value:year_remaining.daysInYear({ date_in })},{name: "fractionIntoYear", value:year_remaining.fractionIntoYear({ timing_in, date_in })}]],"simple_loan":[[{name: "interest_rate", value:simple_loan.interest_rate({ year_in, d_i_year_in, i_in, d_i_in })},{name: "v", value:simple_loan.v({ year_in, d_i_year_in, i_in, d_i_in })},{name: "term", value:simple_loan.term({ term_in })},{name: "year", value:simple_loan.year({ year_in })},{name: "balance", value:simple_loan.balance({ principal_in, d_i_year_in, i_in, d_i_in, missed_repayment_year_in, skip_interest_in, term_in, year_in:simple_loan.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, simple_loan.year({ year_in }) - 1)}},{name: "year", value:simple_loan.year({ year_in })},{name: "interest_rate", value:simple_loan.interest_rate({ year_in, d_i_year_in, i_in, d_i_in })},{name: "balance", value:simple_loan.balance({ principal_in, d_i_year_in, i_in, d_i_in, missed_repayment_year_in, skip_interest_in, term_in, year_in:simple_loan.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, simple_loan.year({ year_in }) - 1)}},{name: "year", value:simple_loan.year({ year_in })},{name: "term", value:simple_loan.term({ term_in })},{name: "year", value:simple_loan.year({ year_in })},{name: "balance", value:simple_loan.balance({ principal_in, d_i_year_in, i_in, d_i_in, missed_repayment_year_in, skip_interest_in, term_in, year_in:simple_loan.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, simple_loan.year({ year_in }) - 1)}},{name: "year", value:simple_loan.year({ year_in })},{name: "interest_rate", value:simple_loan.interest_rate({ year_in, d_i_year_in, i_in, d_i_in })},{name: "v_pow_term_left", value:simple_loan.v_pow_term_left({ year_in, d_i_year_in, i_in, d_i_in, term_in })},{name: "balance", value:simple_loan.balance({ principal_in, d_i_year_in, i_in, d_i_in, missed_repayment_year_in, skip_interest_in, term_in, year_in:simple_loan.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, simple_loan.year({ year_in }) - 1)}},{name: "year", value:simple_loan.year({ year_in })},{name: "interest_rate", value:simple_loan.interest_rate({ year_in, d_i_year_in, i_in, d_i_in })},{name: "repayment", value:simple_loan.repayment({ year_in, missed_repayment_year_in, skip_interest_in, principal_in, d_i_year_in, i_in, d_i_in, term_in })},{name: "interest_repayment", value:simple_loan.interest_repayment({ year_in, missed_repayment_year_in, skip_interest_in, principal_in, d_i_year_in, i_in, d_i_in, term_in })},{name: "repayment", value:simple_loan.repayment({ year_in, missed_repayment_year_in, skip_interest_in, principal_in, d_i_year_in, i_in, d_i_in, term_in })},{name: "interest", value:simple_loan.interest({ year_in, principal_in, missed_repayment_year_in, skip_interest_in, term_in, d_i_year_in, i_in, d_i_in })},{name: "year", value:simple_loan.year({ year_in })},{name: "term", value:simple_loan.term({ term_in })},{name: "year", value:simple_loan.year({ year_in })},{name: "year", value:simple_loan.year({ year_in })},{name: "missed_repayment_year", value:simple_loan.missed_repayment_year({ missed_repayment_year_in })},{name: "skip_interest", value:simple_loan.skip_interest({ skip_interest_in })},{name: "interest", value:simple_loan.interest({ year_in, principal_in, missed_repayment_year_in, skip_interest_in, term_in, d_i_year_in, i_in, d_i_in })},{name: "repayment_due", value:simple_loan.repayment_due({ year_in, term_in })},{name: "repayment_amount", value:simple_loan.repayment_amount({ year_in, principal_in, d_i_year_in, i_in, d_i_in, missed_repayment_year_in, skip_interest_in, term_in })},{name: "year", value:simple_loan.year({ year_in })},{name: "year", value:simple_loan.year({ year_in })},{name: "principal", value:simple_loan.principal({ principal_in })},{name: "balance", value:simple_loan.balance({ principal_in, d_i_year_in, i_in, d_i_in, missed_repayment_year_in, skip_interest_in, term_in, year_in:simple_loan.year({ year_in }) - 1 }), handler: () => {set(viewof year_in, simple_loan.year({ year_in }) - 1)}},{name: "year", value:simple_loan.year({ year_in })},{name: "interest", value:simple_loan.interest({ year_in, principal_in, missed_repayment_year_in, skip_interest_in, term_in, d_i_year_in, i_in, d_i_in })},{name: "repayment", value:simple_loan.repayment({ year_in, missed_repayment_year_in, skip_interest_in, principal_in, d_i_year_in, i_in, d_i_in, term_in })},{name: "year", value:simple_loan.year({ year_in })},{name: "d_i_year", value:simple_loan.d_i_year({ d_i_year_in })},{name: "i", value:simple_loan.i({ i_in })},{name: "d_i", value:simple_loan.d_i({ d_i_in })},{name: "i", value:i}]]}
)}
fns_with_mjs_q_eval ={ return (
{"raycasting2":[[{name:"tan_ray_angle",value:raycasting2.tan_ray_angle({ray_angle_in})},{name:"inverse_tan_ray_angle",value:raycasting2.inverse_tan_ray_angle({ray_angle_in})},{name:"ray_looking_up",value:raycasting2.ray_looking_up({ray_angle_in})},{name:"ray_looking_right",value:raycasting2.ray_looking_right({ray_angle_in})},{name:"map",value:raycasting2.map({})},{name:"map_lookup",value:raycasting2.map_lookup({y_in,x_in})},{name:"rhx",value:raycasting2.rhx({step_in,f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rhy",value:raycasting2.rhy({ray_angle_in,step_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"rhv",value:raycasting2.rhv({step_in,f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rh_hit_object",value:raycasting2.rh_hit_object({f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rh_hit_x",value:raycasting2.rh_hit_x({f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rh_hit_y",value:raycasting2.rh_hit_y({f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rh_hit_v",value:raycasting2.rh_hit_v({f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rh_hit_step",value:raycasting2.rh_hit_step({f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rh_hit_distance",value:raycasting2.rh_hit_distance({y_in,x_in,f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rvx",value:raycasting2.rvx({ray_angle_in,step_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"rvy",value:raycasting2.rvy({step_in,f_in,keys_stream_version_in,keys_stream_function_in,ray_angle_in})},{name:"rvv",value:raycasting2.rvv({ray_angle_in,step_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"rv_hit_object",value:raycasting2.rv_hit_object({ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"rv_hit_x",value:raycasting2.rv_hit_x({ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"rv_hit_y",value:raycasting2.rv_hit_y({ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"rv_hit_v",value:raycasting2.rv_hit_v({ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"rv_hit_step",value:raycasting2.rv_hit_step({ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"rv_hit_distance",value:raycasting2.rv_hit_distance({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"r_hit_h_or_v",value:raycasting2.r_hit_h_or_v({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"r_hit_object",value:raycasting2.r_hit_object({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"r_hit_x",value:raycasting2.r_hit_x({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"r_hit_y",value:raycasting2.r_hit_y({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"r_hit_v",value:raycasting2.r_hit_v({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"r_hit_step",value:raycasting2.r_hit_step({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in})},{name:"fisheye_correction",value:raycasting2.fisheye_correction({fisheye_correction_in})},{name:"ray_distance",value:raycasting2.ray_distance({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in,fisheye_correction_in})},{name:"ray_inverse_distance",value:raycasting2.ray_inverse_distance({y_in,x_in,ray_angle_in,f_in,keys_stream_version_in,keys_stream_function_in,fisheye_correction_in})},{name:"keys_stream_function",value:raycasting2.keys_stream_function({keys_stream_function_in})},{name:"keys_stream_version",value:raycasting2.keys_stream_version({keys_stream_version_in})},{name:"keys",value:raycasting2.keys({keys_stream_version_in,keys_stream_function_in,f_in})},{name:"key_up",value:raycasting2.key_up({keys_stream_version_in,keys_stream_function_in,f_in})},{name:"key_down",value:raycasting2.key_down({keys_stream_version_in,keys_stream_function_in,f_in})},{name:"key_left",value:raycasting2.key_left({keys_stream_version_in,keys_stream_function_in,f_in})},{name:"key_right",value:raycasting2.key_right({keys_stream_version_in,keys_stream_function_in,f_in})},{name:"forwardness",value:raycasting2.forwardness({keys_stream_version_in,keys_stream_function_in,f_in})},{name:"leftness",value:raycasting2.leftness({keys_stream_version_in,keys_stream_function_in,f_in})},{name:"player_angle",value:raycasting2.player_angle({f_in,keys_stream_version_in,keys_stream_function_in})},{name:"player_x",value:raycasting2.player_x({f_in,keys_stream_version_in,keys_stream_function_in})},{name:"player_y",value:raycasting2.player_y({f_in,keys_stream_version_in,keys_stream_function_in})},{name:"speed",value:raycasting2.speed({})},{name:"f",value:raycasting2.f({f_in})},{name:"ray_angle",value:raycasting2.ray_angle({ray_angle_in})},{name:"step",value:raycasting2.step({step_in})},{name:"x",value:raycasting2.x({x_in})},{name:"y",value:raycasting2.y({y_in})}]],"savings":[[{name:"balance",value:savings.balance({year_in,duration_in,annual_payment_in,interest_rate_in})},{name:"deposits",value:savings.deposits({year_in,duration_in,annual_payment_in})},{name:"interest",value:savings.interest({year_in,duration_in,annual_payment_in,interest_rate_in})},{name:"year",value:savings.year({year_in})},{name:"annual_payment",value:savings.annual_payment({annual_payment_in})},{name:"duration",value:savings.duration({duration_in})},{name:"interest_rate",value:savings.interest_rate({interest_rate_in})}]],"savings_rec":[[{name:"year",value:savings_rec.year({year_in})},{name:"actual_interest_rates",value:savings_rec.actual_interest_rates({})},{name:"actual_interest_rate_co",value:savings_rec.actual_interest_rate_co({actual_interest_rate_co_in})},{name:"interest_rate",value:savings_rec.interest_rate({year_in,actual_interest_rate_co_in})}],[{name:"annual_payment",value:savings_rec.annual_payment({})},{name:"duration",value:savings_rec.duration({})}],[{name:"balance",value:savings_rec.balance({year_in,actual_interest_rate_co_in})},{name:"deposits",value:savings_rec.deposits({year_in})},{name:"interest",value:savings_rec.interest({year_in,actual_interest_rate_co_in})}]],"starfield":[[{name:"random_seed",value:starfield.random_seed({random_seed_in})},{name:"seeded",value:starfield.seeded({random_seed_in})},{name:"random",value:starfield.random({random_seed_in})},{name:"frame",value:starfield.frame({frame_in})},{name:"star",value:starfield.star({star_in})},{name:"x0",value:starfield.x0({random_seed_in,star_in})},{name:"y0",value:starfield.y0({random_seed_in,star_in})},{name:"z0",value:starfield.z0({random_seed_in,star_in})},{name:"speed",value:starfield.speed({speed_in})},{name:"z",value:starfield.z({frame_in,random_seed_in,star_in,speed_in})},{name:"visible",value:starfield.visible({frame_in,random_seed_in,star_in,speed_in})},{name:"x",value:starfield.x({frame_in,random_seed_in,star_in,speed_in})},{name:"y",value:starfield.y({frame_in,random_seed_in,star_in,speed_in})},{name:"px",value:starfield.px({frame_in,random_seed_in,star_in,speed_in})},{name:"py",value:starfield.py({frame_in,random_seed_in,star_in,speed_in})}]],"fizzbuzz":[[{name:"fizz",value:fizzbuzz.fizz({i_in})},{name:"buzz",value:fizzbuzz.buzz({i_in})},{name:"fizzbuzz",value:fizzbuzz.fizzbuzz({i_in})},{name:"i",value:fizzbuzz.i({i_in})}]],"year_remaining":[[{name:"date",value:year_remaining.date({date_in})},{name:"year",value:year_remaining.year({date_in})},{name:"isLeap",value:year_remaining.isLeap({date_in})},{name:"daysInYear",value:year_remaining.daysInYear({date_in})},{name:"daysIntoYearStartTomorrow",value:year_remaining.daysIntoYearStartTomorrow({date_in})},{name:"daysIntoYearStartToday",value:year_remaining.daysIntoYearStartToday({date_in})},{name:"daysIntoYear",value:year_remaining.daysIntoYear({timing_in,date_in})},{name:"fractionIntoYear",value:year_remaining.fractionIntoYear({timing_in,date_in})},{name:"fractionLeftInYear",value:year_remaining.fractionLeftInYear({timing_in,date_in})},{name:"timing",value:year_remaining.timing({timing_in})}]],"simple_loan":[[{name:"v",value:simple_loan.v({year_in,d_i_year_in,i_in,d_i_in})},{name:"v_pow_term_left",value:simple_loan.v_pow_term_left({year_in,d_i_year_in,i_in,d_i_in,term_in})},{name:"repayment_amount",value:simple_loan.repayment_amount({year_in,principal_in,d_i_year_in,i_in,d_i_in,missed_repayment_year_in,skip_interest_in,term_in})},{name:"interest",value:simple_loan.interest({year_in,principal_in,missed_repayment_year_in,skip_interest_in,term_in,d_i_year_in,i_in,d_i_in})},{name:"capital_repayment",value:simple_loan.capital_repayment({year_in,missed_repayment_year_in,skip_interest_in,principal_in,d_i_year_in,i_in,d_i_in,term_in})},{name:"interest_repayment",value:simple_loan.interest_repayment({year_in,missed_repayment_year_in,skip_interest_in,principal_in,d_i_year_in,i_in,d_i_in,term_in})},{name:"repayment_due",value:simple_loan.repayment_due({year_in,term_in})},{name:"repayment",value:simple_loan.repayment({year_in,missed_repayment_year_in,skip_interest_in,principal_in,d_i_year_in,i_in,d_i_in,term_in})},{name:"balance",value:simple_loan.balance({year_in,principal_in,d_i_year_in,i_in,d_i_in,missed_repayment_year_in,skip_interest_in,term_in})},{name:"interest_rate",value:simple_loan.interest_rate({year_in,d_i_year_in,i_in,d_i_in})},{name:"principal",value:simple_loan.principal({principal_in})},{name:"i",value:simple_loan.i({i_in})},{name:"term",value:simple_loan.term({term_in})},{name:"year",value:simple_loan.year({year_in})},{name:"missed_repayment_year",value:simple_loan.missed_repayment_year({missed_repayment_year_in})},{name:"skip_interest",value:simple_loan.skip_interest({skip_interest_in})},{name:"d_i_year",value:simple_loan.d_i_year({d_i_year_in})},{name:"d_i",value:simple_loan.d_i({d_i_in})}]]}
)}
/////////// end copy, don't delete the following:
i = 0 // allows for bug processing simple_loan
{
window.fns_with_mjs_q_eval = fns_with_mjs_q_eval
window.mjs_q_eval = mjs_q_eval
// trigger an update animation here, but is that good without checking if individual numbers changed ?
// setup a history?
}
{
// can I make this run on editor scroll? or make CM generate full dom?
//document.getElementById('a-'+32).textContent = fmt(fns_with_mjs_q_eval[32]);
// Seems like these cells stop if there is a single error,
// like modifying an element that isn't yet created
// Quarto/OJS gives no error!
// maybe due to output: false? DANGEROUS
//console.log('UPDATE')
fns_with_mjs_q_eval[modelname][cul_scope_id].forEach((v, i) => {
let d = document.getElementById('a-'+i)
if (d)
d.textContent = fmt2(v.name, v.value)//fmt(v);
})
mjs_q_eval[modelname][cul_scope_id].forEach(({name, value}, i) => {
let d = document.getElementById('w-'+i)
if (d) document.getElementById('w-'+i).textContent = fmt2(name, value); // does this get used? on update?
})
}
// todo fmt hints or templates? like a type or unit?
// is this a big bottleneck?
fmt2 = (name, value) => {
name = name.toLowerCase();
if (name == 'x' || name == 'y') return d3.format(',.4f')(value)
if (name == "map") return "[[..]]"
if (Array.isArray(value)) return "[..]"
if (modelname == 'fizzbuzz') return typeof value == 'number' ? d3.format(',.0f')(value) : value // works well for fizzbuzz
if (name == 'now' || name == 'date') return d3.timeFormat("%Y-%m-%d")(value)
if (modelname == 'emissions_my_lifetime') {
if (name == 'now') return d3.timeFormat("%Y-%m-%d")(value)
if (name == "emissions_my_lifetime_proportion") return d3.format(".3%")(value)
if (typeof value == 'number')
return d3.format(".5k")(value)
}
if (name == "v") return d3.format(",.5f")(value)
if (name == "v_pow_term_left") return d3.format(",.5f")(value)
if (name.includes("_hit_object")) return "{..}"//`{x: ${value.x.toFixed(2)}, y: ${value.y.toFixed(2)}, v: ${value.v}, step_in: ${value.step_in}}`
if (name.includes("_co")) return d3.format(",.0f")(value)
if (name.includes("rate") && name.includes("interest")) return d3.format(".3%")(value)
if (name.includes("rate") || name.includes("percent") || name.includes("fraction")) return d3.format(".2%")(value)
if ((name.includes("year")) || name.includes("term") || name.includes("duration") || name.includes("frame")) return d3.format(".0f")(value)
if (name.includes("object") || typeof value != 'number') return JSON.stringify(value)
return d3.format(fmt_fmt)(value)
}
////
// how to call a function
fns_with_mjs = Object.values(calculang_source_introspection.cul_functions)
.filter(
(d) =>
d.reason == "definition" /*input definition doesn't have a loc*/ &&
d.cul_scope_id == cul_scope_id
)
.map((d) => ({ ...d, mjs: `{${d.inputs.join(",")}}` })) // assuming completely on one line
// ex- calls_with_mjs, relates to that in generator
calls = calculang_source_introspection.cul_links
.filter(d => !d.from.includes('undefined')).filter((d) => d.reason == "call" && cul_scope_id == +d.to.split("_")[0]) // bugs for double digit scopes
// ex CheckboxWidget
class AnswersWorkingsOverlayWidget extends cmImports.view.WidgetType {
constructor(v, call, call_i, type) {
//a = v;
super();
this.v = v;
this.call = call;
this.call_i = call_i;
this.type = type;
//this.evals = type == "definition" ? mjs_q_eval : fns_with_mjs_q_eval;
//this.info = type == "definition" ? fns_with_mjs : calls_with_mjs_qualified;
}
toDOM() {
// mjs_q_eval; use this to test flicker/parse issues for plugins setting values (now set setparately by DOM calls)
let wrap = document.createElement("span");
//wrap.className = "tooltip";
//wrap.textContent = "101.19";
wrap.setAttribute("aria-hidden", "true"); // not in a good place, todo fix
wrap.className = "calculang_tooltip";
if (this.type == "definition") {
return htl.html`<span class="calculang_tooltip answer" id="c-a-${this.v}"><!--<input type="checkbox"></input>--><span id="a-${this.v}" class="tooltiptext" anchor="c-a-${this.v}">${fmt2(
window.fns_with_mjs_q_eval[modelname][cul_scope_id][this.v].name, window.fns_with_mjs_q_eval[modelname][cul_scope_id][this.v].value//999
)}</span></span>`;
}
return htl.html`<span onclick=${() => {
/* TODO*/ set(viewof formulae_visible, [ // I'm supposed to use options.formulae_visible !!
calls[this.v].from.slice(2)
]);
document.querySelector('.calculang_f_'+calls[this.v].from.slice(2)/*BUG for >9 scopes!*/).scrollIntoView(scrollIntoViewOpts)
if (window.mjs_q_eval[modelname][cul_scope_id][this.v].handler) window.mjs_q_eval[modelname][cul_scope_id][this.v].handler();
}} class="calculang_tooltip" id="c-w-${this.call_i}"><!-- <input type="checkbox"></input>--><span id="w-${this.call_i}" class="tooltiptext" anchor="c-w-${this.call_i}">${fmt2( window.mjs_q_eval[modelname][cul_scope_id][this.call_i].name,
window.mjs_q_eval[modelname][cul_scope_id][this.call_i].value
)}</span></span>`;
return wrap;
}
ignoreEvent() {
return false;
}
}
function workings(view) {
return Decoration.set(
[
...calls.map((d, i) =>
Decoration.widget({
widget: new AnswersWorkingsOverlayWidget(i, d, i),
side: 1
}).range(
d.loc.start.index +
d.from.length -
0 - Math.floor(d.from.length/2) // this split is wrong for interest_rate for example!
)
)
]
);
}
function answers(view) {
return Decoration.set(
[