Skip to content

Commit

Permalink
Updated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
PESchoenberg committed Jan 5, 2019
1 parent 357f22a commit 8bc8e27
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# grsp - Useful Scheme functions.

[![DOI](https://zenodo.org/badge/163432499.svg)](https://zenodo.org/badge/latestdoi/163432499)


## Overview:
Expand Down
12 changes: 10 additions & 2 deletions examples/example1.scm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

; Reqired modules.
(use-modules (grsp grsp0))
(use-modules (grsp grsp1))


; Remember what this program is about (optional).
Expand All @@ -49,17 +50,24 @@
(ptit "=" 60 2 q)

; pline
(ptit " " 1 1 "pline samples")
(ptit " " 1 1 "1 - pline samples:")
(pline "-" 20)
(pline "*" 40)
(pline "=" 60)

; ptit
(ptit " " 1 1 "ptit samples")
(ptit " " 1 1 "2 - ptit samples")
(ptit "*" 60 1 "ptit function with 1 line of '*', 60 in length.")
(ptit "/" 40 2 "ptit function with 2 lines of '/', 40 in length.")


; gconst
(ptit " " 1 0 "3 - gconst samples and use of newlines and pres functions:")
(newlines 1)
(pres "Pi" (number->string (gconst "Pi")))
(pres "gr" (number->string (gconst "gr")))





21 changes: 20 additions & 1 deletion grsp0.scm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
;#:use-module ()
#:export (pline
ptit
newlines))
newlines
pres))


; pline - displays character p_n p_m times in one line at the console.
Expand Down Expand Up @@ -84,6 +85,24 @@
)


; pres - dispay results.
;
; Arguments:
; - p_s1: reference, string.
; - p_s2: result, string
;
(define (pres p_s1 p_s2)
(let ((res " "))
(set! res (string-append p_s1 (string-append " = " p_s2)))
(display res)
(newline)
)
)








Expand Down
48 changes: 48 additions & 0 deletions grsp1.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
; ==============================================================================
;
; grsp1.scm
;
; Constants.
;
; ==============================================================================
;
; Copyright (C) 2018 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/>.
;
; ==============================================================================


(define-module (grsp grsp1)
;#:use-module ()
#:export (gconst))


; qconst - various constants.
;
; Arguments:
; - p_n1: constant name, string.
;
(define (gconst p_n1)
(let ((res 0))
(cond ((equal? p_n1 "Pi")(set! res 3.14159)) ; Pi
((equal? p_n1 "gr")(set! res 1.00)) ;
((equal? p_n1 "e")(set! res 2,71828)) ; Euler's number.
(else (set! res 0)))
res)
)




0 comments on commit 8bc8e27

Please sign in to comment.