<-- Go Back
JSchemePlus
(share it)
JSchemePlus is an hack of Jscheme 1.4 by Peter Norvig. It is basically the same, however it allows to redistribute a script in an executable JAR file of only ~40K, simply make a copy of runtime.jar
, e.g. cp runtime.jar my-jar.jar
, name the script as main.scm
and insert into this JAR, e.g. zip -u my-jar.jar main.scm
, then execute it, e.g. java -jar my-jar.jar
JSchemePlus does not get command-line arguments as list of scripts to execute, only the first one is executed, the others are passed to this script and stored as list of strings in *arguments*
. It implements all of R4RS with a lot of additional functions, like: (execute command) (random) (sequence from up-to step) (split list element) (string-split string sub-string) (read-all-from-file file) (write-to-file file data) (file-size file) etc...
For the complete list read the HELP file or type (help)
.
JSchemePlus needs only the Java Virtual Machine (version 6 or higher) that, in the case, is very easy to download and install; click here to get it for any operating system.
About Scheme, it is a Lisp dialect that allows to write programs and scripts quickly and easly. It is a different language, even compared to other Lisps; it is not difficult, only a bit different. The following is an example of recursion:
(define (sequence from up-to step)
(if (and (integer? from) (integer? up-to) (integer? step) (<= from up-to) (positive? step))
(let ((_sequence '()))
(define (loop _var)
(if (< _var from)
_sequence
(begin
(set! _sequence (cons _var _sequence))
(loop (- _var step))
)
)
)
(loop up-to)
)
'()
)
)
The following is an example of iteration:
(for-each (lambda (_num)
(if (odd? _num)
(display _num)
(newline)
)
) (sequence 1 10 1))
1
3
5
7
9
()
It checks each number from 1 to 10, if this is odd it prints this, otherwise it prints a newline. Finally, it returns nothing (empty list). For more information and examples, see the reference documentation.
DOWNLOAD
(1.4PF)
-
JSchemePlus (and every thing with it) is released under the simplified BSD license:
Copyright (c) 2025, Pasquale Frega
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.