-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrsp0.scm
3569 lines (3074 loc) · 64.9 KB
/
grsp0.scm
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
;; =========================================================================
;;
;; grsp0.scm
;;
;; A library of some useful, simple functions for GNU Guile Scheme programs
;; created or adapted during the development of several other projects.
;;
;; =========================================================================
;;
;; Copyright (C) 2018 - 2024 Pablo Edronkin (pablo.edronkin at yahoo.com)
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Lesser General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU Lesser General Public License for more details.
;;
;; You should have received a copy of the GNU Lesser General Public
;; License along with this program. If not, see
;; <https://www.gnu.org/licenses/>.
;;
;; =========================================================================
;;;; General notes:
;;
;; - Read sources for limitations on function parameters.
;; - Read at least the general notes of all scm files in this library before
;; use.
;;
;; - Compilation:
;;
;; - (use-modules (grsp grsp0)(grsp grsp1)(grsp grsp2)(grsp grsp3)(grsp grsp4)(grsp grsp5)(grsp grsp6)(grsp grsp7)(grsp grsp8)(grsp grsp9)(grsp grsp10)(grsp grsp11)(grsp grsp12)(grsp grsp13)(grsp grsp14)(grsp grsp15)(grsp grsp16)(grsp grsp17))
;;
;; Sources:
;;
;; See code of functions used and their respective source files for more
;; credits and references.
;;
;; - [1] Shido.info. (2019). 9. IO. [online] Available at:
;; http://www.shido.info/lisp/scheme9_e.html [Accessed 15 Sep. 2019].
;; - [2] Gnu.org. (2019). File Ports (Guile Reference Manual). [online]
;; Available at:
;; https://www.gnu.org/software/guile/manual/html_node/File-Ports.html
;; [Accessed 15 Sep. 2019].
;; - [3] Edronkin, P. (2019). sqlp - Simple terminal query and .sql file
;; processing for Sqlite3. [online] sqlp. Available at:
;; https://peschoenberg.github.io/sqlp/ [Accessed 5 Oct. 2019].
;; - [4] Gnu.org. 2021. Dynamic Types (Guile Reference Manual). [online]
;; Available at:
;; https://www.gnu.org/software/guile/manual/html_node/Dynamic-Types.html
;; [Accessed 1 October 2021].
;; - [5] Gnu.org. 2021. Data Types (Guile Reference Manual). [online]
;; Available at:
;; https://www.gnu.org/software/guile/manual/html_node/Data-Types.html
;; [Accessed 1 October 2021].
;; - [6] Academic.oup.com. 2021. How the strengths of Lisp-family languages
;; facilitate building complex and flexible bioinformatics applications.
;; Bohdan B Khomtchouk, Edmund Weitz, Peter D Karp, Claes Wahlestedt.
;; [online] Available at:
;; https://academic.oup.com/bib/article-pdf/19/3/537/25603287/bbw130.pdf
;; [Accessed 11 October 2021].
;; - [7] En.wikipedia.org. 2022. Mathematics Subject Classification -
;; Wikipedia. [online] Available at:
;; https://en.wikipedia.org/wiki/Mathematics_Subject_Classification
;; [Accessed 16 June 2022].
;; - [8] En.wikipedia.org. 2022. ACM Computing Classification System -
;; Wikipedia. [online] Available at:
;; https://en.wikipedia.org/wiki/ACM_Computing_Classification_System
;; [Accessed 16 June 2022].
;; - [9] List of terms relating to algorithms and data structures (2023)
;; Wikipedia. Wikimedia Foundation. Available at:
;; https://en.wikipedia.org/wiki/List_of_terms_relating_to_algorithms_and_data_structures
;; (Accessed: February 8, 2023).
;; - [10] Dictionary of algorithms and Data Structures (no date) NIST.
;; Available at: https://www.nist.gov/dads/ (Accessed: February 8, 2023).
;; - [11] Scheme requests for implementation (no date) Scheme Requests for
;; Implementation. Available at: https://srfi.schemers.org/
;; (Accessed: 29 July 2023).
;; - [12] Practical scheme (no date) Practical Scheme. Available at:
;; https://practical-scheme.net/ (Accessed: 29 July 2023).
;; - [13] Project MAC (‘Switzerland’) (no date) Project MAC Home Page.
;; Available at: http://groups.csail.mit.edu/mac/projects/mac/
;; (Accessed: 29 July 2023).
;; - [14] https://www.gnu.org/software/guile/manual/html_node/Pipes.html
;; - [15] https://askubuntu.com/questions/859975/how-to-know-the-vertical-position-of-the-command-prompt
;; - [16] https://www.codeproject.com/Articles/5329247/How-to-Change-Text-Color-in-a-Linux-Terminal
;; . [17] https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html
;; - [18] https://www.draketo.de/software/guile-capture-stdout-stderr.html
(define-module (grsp grsp0)
#:use-module (grsp grsp3)
#:use-module (grsp grsp1)
#:use-module (grsp grsp11)
#:use-module (ice-9 string-fun)
#:use-module (ice-9 futures)
#:use-module (ice-9 binary-ports)
#:use-module (ice-9 popen)
#:use-module (ice-9 rdelim)
#:export (pline
plinetn
ptit
newlines
clear
pres
pres2
newspaces
strings-append
read-file-as-string
call-command-with-output-error-to-string
grsp-lang-effective-version
grsp-test
grsp-save-to-file
grsp-delete-file
grsp-n2s
grsp-s2n
grsp-sqlp
grsp-ld
grsp-dl
grsp-ldl
grsp-ldvl
grsp-cd
grsp-ask
grsp-askn
grsp-ask-etc
grsp-placebo
in
de
grsp-bcn2s
grsp-argtype
grsp-dstr
grsp-jstr
grsp-hw
grsp-gb
grsp-string-tlength
grsp-string-ltlength
grsp-string-ltrim
grsp-string-pjustify
grsp-string-repeat
grsp-string-lpjustify
grsp-ln2ls
grsp-ls2ln
grsp-ls2ss
grsp-ls2s
grsp-s2ln
grsp-ln2s
grsp-generate-file-name
grsp-list-file-name
grsp-trprnd
grsp-intercal
grsp-s2dbc
grsp-ln2ns
grsp-dbc2s
grsp-lns2ln
grsp-dsc
grsp-dscn
grsp-dline
grsp-dtext
displayl
displayf
grsp-slists-append
grsp-lam
grsp-random-state-set
displayc
grsp-confirm
grsp-b2s
grsp-s2b
grsp-y2s
grsp-nan2s
grsp-s2nan
grsp-inf2s
grsp-s2inf
grsp-s2y
grsp-confirm-ask
grsp-art1
grsp-art2
grsp-string-is-number
grsp-art3
grsp-s2qs
grsp-touch-lf
grsp-sldvls
grsp-clear-on-demand
grsp-ldlc
grsp-pad-lr
grsp-menuv
grsp-menub
grsp-menup
grsp-menufv
grsp-menufb
grsp-piped
clearl
grsp-color-set
grsp-wrc
grsp-movc
plinerc
grsp-file-isolate-name
grsp-pg-psql1
grsp-count-words
grsp-string-lo
grsp-substring-replace
grsp-substring-delete-shorter
grsp-ask2s
grsp-askn2s
grsp-menud
grsp-display-scr
grsp-menu-date
grsp-row-menu))
;;;; pline - Displays string p_s1 p_l1 times in one line at the console.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: line character to display.
;; - p_l1: line length.
;;
;; Examples:
;;
;; - example1.scm, example3.scm.
;;
;; Output:
;;
;; - String.
;;
(define (pline p_s1 p_l1)
(let ((s1 ""))
;; Cycle.
(let loop ((i1 0))
(if (= i1 p_l1)
(begin (newline)
(display s1)
(newline))
(begin (set! s1 (string-append s1 p_s1))
(loop (+ i1 1)))))))
;;;; plinetn - Same as pline but applies the string to the total width of
;; the shell or terminal.
;;
;; Keywords:
;;
;; - pline, terminal, decoration
;;
;; Parameters:
;;
;; - p_s1: line character to display.
;;
(define (plinetn p_s1)
(let ((res1 9))
(pline p_s1 (grsp-s2n (grsp-piped "tput cols")))
res1))
;;;; ptit - Displays a console title with one or two lines.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: line string to display.
;; - p_l1: line length.
;; - p_n1: number of lines (1 or 2, defaults to 1 line above title).
;; - p_t1: title to display.
;;
;; Examples:
;;
;; - example1.scm, example3.scm.
;;
;; Output:
;;
;; - String.
;;
(define (ptit p_s1 p_l1 p_n1 p_t1)
(if (<= p_n1 1)
(pline p_s1 p_l1))
(if (>= p_n1 2)
(pline p_s1 p_l1))
(display p_t1)
(if (>= p_n1 2)
(pline p_s1 p_l1))
(newline))
;;;; newlines - Repeats function newline p_n1 times.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_n: number of iterations.
;;
(define (newlines p_n1)
(let loop ((i1 0))
(if (<= i1 p_n1)
(begin (newline)
(loop (+ i1 1))))))
;;;; clear - Clears the terminal or shell by inserting 100 blank lines.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Examples:
;;
;; - example3.scm.
;;
(define (clear)
(newlines 100))
;;;; pres - Display results with a reference string or title and an equal
;; sign preceeding the results string.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: reference, string.
;; - p_s2: result, string.
;;
;; Notes:
;;
;; - See pres2.
;;
;; Examples:
;;
;; - example1.scm.
;;
;; Output:
;;
;; - String.
;;
(define (pres p_s1 p_s2)
(let ((res1 " "))
(set! res1 (string-append p_s1 (string-append " = " p_s2)))
(display res1)
(newline)))
;;;; pres2 - Display results. Does not require p_s2 to be a string.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: reference, string.
;; - p_s2: result.
;;
;; Notes:
;;
;; - See pres.
;;
;; Output:
;;
;; - String.
;;
(define (pres2 p_s1 p_s2)
(newline)
(display p_s1)
(display " = ")
(display p_s2)
(newline))
;;;; newspaces - Adds p_n blank spaces to string p_l1.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_n1: number of blanks to add.
;; - p_l1: string to display.
;; - p_s1: side where to add spaces,
;;
;; - 0 for left side.
;; - 1 for right side.
;;
;; Examples:
;;
;; - example1.scm.
;;
;; Output:
;;
;; - String.
;;
(define (newspaces p_n1 p_l1 p_s1)
(let ((res1 " ")
(s1 ""))
(set! res1 p_l1)
;; Create a string of blanks.
(let loop ((i1 0))
(if (< i1 p_n1)
(begin (set! s1 (string-append s1 " "))
(loop (+ i1 1)))))
;; Add the blank string.
(if (= p_s1 0)
(set! res1 (string-append s1 res1)))
(if (= p_s1 1)
(set! res1 (string-append res1 s1)))
res1))
;;;; strings-append - Appends strings entered in a list as one larger
;; string. Use it to avoid complex, nested calls to string-append when
;; you have to join several strings into one.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_l1: list of strings.
;; - p_s1: add a blank space after each list element.
;;
;; - 0 for no spaces.
;; - 1 to add one blank space.
;;
;; Examples:
;;
;; - example1.scm, example3.scm.
;;
;; Output:
;;
;; - String.
;;
(define (strings-append p_l1 p_s1)
(let ((res1 "")
(elem #f))
;; Cycle.
(set! elem (car p_l1))
(while (not (equal? elem #f))
(if (equal? p_s1 1)
(set! elem (string-append elem " ")))
(set! res1 (string-append res1 elem))
(set! p_l1 (cdr p_l1))
(if (> (length p_l1) 0)
(set! elem (car p_l1)))
(if (= (length p_l1) 0)
(set! elem #f)))
res1))
;;;; read-file-as-string - Reads a file as a string; adapted from an
;; example from sources indicated below. The string will be formatted and
;; include characters such as \n and \r. What this does in practice is to
;; read a file and return it as one single string.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_f1: file name.
;;
;; Sources:
;;
;; - [1].
;;
;; Output:
;;
;; - String.
;;
(define (read-file-as-string p_f1)
(call-with-input-file p_f1
(lambda (p1)
(let loop((ls1 '()) (c1 (read-char p1)))
(if (eof-object? c1)
(begin (close-input-port p1)
(list->string (reverse ls1)))
(loop (cons c1 ls1) (read-char p1)))))))
;;;; read-port-as-string - Reads terminal output as a string.
;;
;; Keywords:
;;
;; - console, terminal, strings
;;
;; Parameters:
;;
;; - p_p1: port.
;;
;; Notes:
;;
;; - This is an imported function. Credit goes to sources (lic lgplv2 or later).
;;
;; Sources:
;;
;; - [18].
;;
;; Output:
;;
;; - String.
;;
(define (call-command-with-output-error-to-string cmd)
(let* ((err-cons (pipe))
(port (with-error-to-port (cdr err-cons)
(λ() (open-input-pipe cmd))))
(_ (setvbuf (car err-cons) 'block
(* 1024 1024 16)))
(result (read-delimited "" port)))
(close-port (cdr err-cons))
(values
result
(read-delimited "" (car err-cons)))))
;;;; grsp-lang-effective-version - Checks if currently instaled GNU Guile's
;; effective version is less, equal or higher than value of the version
;; argument.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: enter the one of the following strings.
;;
;; - "lt" less than.
;; - "eq" equal to.
;; - "ht" higher than.
;;
;; - p_v1: version number to check against.
;;
;; Examples:
;;
;; - example1.scm.
;;
;; Output:
;;
;; - Boolean. Defaults to #f if p_s1 is entered incorrectly.
;;
(define (grsp-lang-effective-version p_s1 p_v1)
(let ((res1 #f)
(ev (string->number (effective-version))))
(if (equal? p_s1 "lt")
(set! res1 (< ev p_v1)))
(if (equal? p_s1 "eq")
(set! res1 (= ev p_v1)))
(if (equal? p_s1 "ht")
(set! res1 (> ev p_v1)))
res1))
;;;; grsp-test - A simple test function.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Output:
;;
;; - String.
;;
(define (grsp-test)
(grsp-ld "grsp-test"))
;;;; grsp-save-to-file - Saves a string to string file p_f1.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string to save.
;; - p_f1: file.
;; - p_m1: save mode.
;;
;; - "w": open for input. Rewrite if exists.
;; - "a": open for append. Create if does not exist.
;; - "wb w": open for binary input.
;; - "ab a": open for binary append.
;;
;; Output:
;;
;; - File.
;;
;; Sources:
;;
;; - [2].
;;
(define (grsp-save-to-file p_s1 p_f1 p_m1)
(let ((output-port (open-file p_f1 p_m1)))
(display p_s1 output-port)
(newline output-port)
(close output-port)))
;;;; grsp-delete-file - Deletes file p_f1.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: mode:
;;
;; - "#f": equivalent to rm -f, without confirmation.
;; - "#c": eqivalent to rm, with confirmation.
;;
;; - p_f1: file name.
;;
(define (grsp-delete-file p_s1 p_f1)
(let ((s1 p_s1)
(s2 "rm")
(s3 ""))
(cond ((equal? p_s1 "#f")
(set! s3 "-f")))
(system (strings-append (list s2 s3 p_f1) 1))))
;; grsp-n2s - A convenience function, shorter to write than number->string
;; that performs the same function. That is, to convert a number to a
;; string.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_n1: number to convert.
;;
;; Output:
;;
;; - String.
;;
(define (grsp-n2s p_n1)
(let ((res1 ""))
(set! res1 (number->string p_n1))
res1))
;;;; grsp-s2n - A convenience function, shorter to write than
;; string->number that performs the same function. That is, to convert a
;; string to a number.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string to convert.
;;
;; Output:
;;
;; - Numeric.
;;
;;
(define (grsp-s2n p_s1)
(let ((res1 0.0))
(set! res1 (string->number p_s1))
res1))
;;;; grsp-sqlp - Calls sqlp to access Sqlite3 or HDF5 databases from
;; within a Guile program. Requires sqlp to be installed.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_p1: path to the sqlp executable.
;; - p_d1: database file, with path.
;; - p_s1: SQL or HDFQL snippet or file, with path.
;; - p_a1: sqlp macro (see sqlp's documentation for more on this).
;;
;; Sources:
;;
;; - [3].
;;
(define (grsp-sqlp p_p1 p_d1 p_s1 p_a1)
(system (strings-append (list p_p1 p_d1 p_s1 p_a1) 1)))
;;;; grsp-ld - Line and display. Displays a string after a newline.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string.
;;
;; Examples:
;;
;; - example3.scm.
;;
;; Output:
;;
;; - String.
;;
(define (grsp-ld p_s1)
(newline)
(display p_s1))
;;;; grsp-dl - Display and line. Displays a newline after a string.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string.
;;
;; Output:
;;
;; - String.
;;
(define (grsp-dl p_s1)
(display p_s1)
(newline))
;;;; grsp-ldl - Line, display. line. Displays p_n1 blank lines before
;; string p_s1 and p_n2 blank lines after p_s1.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string.
;; - p_n1: number of new lines preceeding the string.
;; - p_n2: number of new lines after the string.
;;
;; Examples:
;;
;; - example3.scm.
;;
;; Output:
;;
;; - String.
;;
(define (grsp-ldl p_s1 p_n1 p_n2)
(let ((n1 0))
(set! n1 (- p_n1 1))
(cond ((< n1 0)
(set! n1 0)))
(newlines n1)
(display p_s1)
(newlines p_n2)))
;;;; grsp-ldvl - Line, display value, line. Displays p_n1 blank lines
;; before string p_s1 and p_n2 blank lines after p_s1.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string (i.e. description or title of p_v1).
;; - p_v1: value.
;; - p_n1: number of new lines preceeding the string.
;; - p_n2: number of new lines after the string.
;;
;; Examples:
;;
;; - example28.scm.
;;
;; Output:
;;
;; - String.
;;
(define (grsp-ldvl p_s1 p_v1 p_n1 p_n2)
(let ((n1 0))
(set! n1 (- p_n1 1))
(cond ((< n1 0)
(set! n1 0)))
(newlines n1)
(display p_s1)
(display " ")
(display p_v1)
(newlines p_n2)))
;;;; grsp-cd - Same as grsp-ld, but performs a clear instead of newline,
;; meaning that it clears the screen or console instead of just adding a
;; line break.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string.
;;
;; Output:
;;
;; - String.
;;
(define (grsp-cd p_s1)
(clear)
(display p_s1))
;;;; grsp-ask - Input query, string.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string representing the question to ask.
;;
;; Examples:
;;
;; - example3.scm.
;;
;; Notes:
;;
;; - https://stackoverflow.com/questions/59006417/how-to-read-a-string-to-get-user-input-in-gnu-guile
;;
;; Output:
;;
;; - Returns data from the user's input. You may need to use
;; symbol->[type] in order to return the proper type variable for your
;; needs.
;;
(define (grsp-ask p_s1)
(let ((res1 " "))
(newline)
(grsp-ld p_s1)
(set! res1 (read))
res1))
;;;; grsp-askn - Input query for numbers.
;;
;; Keywords:
;;
;; - console, numbers
;;
;; Parameters:
;;
;; - p_s1: string representing the question to ask.
;;
;; Output:
;;
;; - Numeric. Returns data from the user's input as a number.
;;
(define (grsp-askn p_s1)
(let ((res1 0))
(newline)
(grsp-ld p_s1)
(set! res1 (read))
res1))
;;;; grsp-ask-etc - Asks to press <ENT> to continue.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Examples:
;;
;; - example3.scm
;;
;; Output:
;;
;; - A question asking to press <ENT> to continue.
;;
(define (grsp-ask-etc)
(let ((res1 " "))
(grsp-ask (gconsts "pec"))
res1))
;;;; grsp-placebo - This function is a placebo.
;;
;; Keywords:
;;
;; - console, strings
;;
;; Parameters:
;;
;; - p_s1: string or number.
;;
;; Output:
;;
;; - Returns p_s1.
;;
(define (grsp-placebo p_s1)
(let ((res1 p_s1))
;; Does nothing, which sometimes can be useful.
res1))
;; in - Increments p_n1 by one.
;;
;; Keywords:
;;
;; - console, numbers
;;
;; Parameters:
;;
;; - p_n1: number.
;;
;; Output:
;;
;; - Numeric.
;;
(define (in p_n1)
(let ((res1 0))
(set! res1 (+ p_n1 1))
res1))
;; de - Decrements p_n1 by one.
;;
;; Keywords: