Skip to content

Commit

Permalink
Merge pull request #6 from PESchoenberg/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
PESchoenberg authored Mar 1, 2019
2 parents ff89ddc + 93b441a commit 6f1e4ff
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Some useful functions for GNU Guile Scheme programs.

## Dependencies:

* GNU Guile - ver 2.0. or newer ( https://www.gnu.org/software/guile/ )
* GNU Guile - ver 2.2.3 or newer ( https://www.gnu.org/software/guile/ )


## Installation:
Expand All @@ -22,16 +22,16 @@ into a folder of your choice and cd into it.
details concerning your OS and distribution, but as an example, on Ubuntu you
would issue:

sudo mkdir /usr/share/guile/site/2.0/grsp
sudo mkdir /usr/share/guile/site/2.2/grsp

sudo cp *.scm -rv /usr/share/guile/site/2.0/grsp
sudo cp *.scm -rv /usr/share/guile/site/2.2/grsp

and that will do the trick.


## Uninstall:

* You just need to remove /usr/share/guile/site/2.0/grsp and its subfolders.
* You just need to remove /usr/share/guile/site/2.2/grsp and its subfolders.

* There are no other dependencies.

Expand Down
50 changes: 47 additions & 3 deletions examples/example1.scm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,51 @@
(display res)
(newlines 1)




; Environment (interpreter ) version analysis.
(ptit " " 1 1 "6 - Version:")
(newline)
(display "Your current GNU Guile version is ")
(display (version))
(display " and your current effective version is ")
(display (effective-version))
(newlines 2)

(define ver 1.8)
(display (strings-append (list "Regarding effective version " (number->string ver) " your Scheme effective version is: ") 0))
(newline)
(display "Lower? ")
(display (grsp-lang-effective-version "lt" ver))
(newline)
(display "Equal? ")
(display (grsp-lang-effective-version "eq" ver))
(newline)
(display "Higher? ")
(display (grsp-lang-effective-version "ht" ver))
(newlines 2)

(set! ver 2.0)
(display (strings-append (list "Regarding version " (number->string ver) " your Scheme version is: ") 0))
(newline)
(display "Lower? ")
(display (grsp-lang-effective-version "lt" ver))
(newline)
(display "Equal? ")
(display (grsp-lang-effective-version "eq" ver))
(newline)
(display "Higher? ")
(display (grsp-lang-effective-version "ht" ver))
(newlines 2)

(set! ver 2.2)
(display (strings-append (list "Regarding version " (number->string ver) " your Guile Scheme version is: ") 0))
(newline)
(display "Lower? ")
(display (grsp-lang-effective-version "lt" ver))
(newline)
(display "Equal? ")
(display (grsp-lang-effective-version "eq" ver))
(newline)
(display "Higher? ")
(display (grsp-lang-effective-version "ht" ver))
(newlines 2)

29 changes: 24 additions & 5 deletions grsp0.scm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
pres
newspaces
strings-append
read-file-as-string))
read-file-as-string
grsp-lang-effective-version))


; pline - displays character p_n p_m times in one line at the console.
Expand All @@ -50,7 +51,7 @@
(loop (+ i 1)))))))


; ptit - displays a console title surrounded by one or two lines.
; ptit - displays a console title with one or two lines.
;
; Arguments:
; - p_c: line character to display.
Expand Down Expand Up @@ -144,7 +145,7 @@
; 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.
; file and return it as one single string.
;
; Arguments:
; - p_f: file name.
Expand All @@ -163,5 +164,23 @@
(loop (cons c ls1) (read-char p)))))))




; Checks if currently instaled GNU Guile's effective version is less, equal or
; higher than value of the version argument vakue.
;
; Arguments:
; - p_s: enter the one of the following strings.
; - "lt" less than.
; - "eq" equal to.
; - "ht" higher than.
; - p_v: version number to check against.
;
; Output:
; - Boolean. Defaults to #f if p_s is entered incorrectly.
;
(define (grsp-lang-effective-version p_s p_v)
(let ((res #f)
(ev (string->number (effective-version))))
(if (equal? p_s "lt")(set! res (< ev p_v)))
(if (equal? p_s "eq")(set! res (= ev p_v)))
(if (equal? p_s "ht")(set! res (> ev p_v)))
res))

0 comments on commit 6f1e4ff

Please sign in to comment.