mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-26 07:04:27 +00:00
capitalize constants
This commit is contained in:
parent
be9ffae2e8
commit
c0fb53742a
@ -338,10 +338,10 @@ The following constants are defined by default:
|
|||||||
|
|
||||||
Name | PHP constant
|
Name | PHP constant
|
||||||
------- | ------------
|
------- | ------------
|
||||||
dirsep | DIRECTORY_SEPARATOR
|
DIRSEP | DIRECTORY_SEPARATOR
|
||||||
homedir | $_SERVER['HOME']
|
HOME | $_SERVER['HOME']
|
||||||
ln | PHP_EOL
|
EOL | PHP_EOL
|
||||||
pi | M_PI
|
PI | M_PI
|
||||||
|
|
||||||
## Extending
|
## Extending
|
||||||
|
|
||||||
|
@ -41,14 +41,14 @@
|
|||||||
((first cmd) args))))))
|
((first cmd) args))))))
|
||||||
|
|
||||||
;; Define a file for readline and load it
|
;; Define a file for readline and load it
|
||||||
(def readlineFile (str homedir "calc_history"))
|
(def readlineFile (str HOME "calc_history"))
|
||||||
(readlineLoad readlineFile)
|
(readlineLoad readlineFile)
|
||||||
|
|
||||||
;; Main loop: Read input from user, add it to readline, and parse it
|
;; Main loop: Read input from user, add it to readline, and parse it
|
||||||
(def mainLoop (fn () (let (inp (readline "> "))
|
(def mainLoop (fn () (let (inp (readline "> "))
|
||||||
(do (readlineAdd inp)
|
(do (readlineAdd inp)
|
||||||
(readlineSave readlineFile)
|
(readlineSave readlineFile)
|
||||||
(print (str (parseInput inp) "\n"))
|
(print (str (parseInput inp) EOL))
|
||||||
true))))
|
true))))
|
||||||
|
|
||||||
;; Run it
|
;; Run it
|
||||||
|
@ -8,8 +8,8 @@ class IO implements ILib
|
|||||||
{
|
{
|
||||||
public function register(Env $env): void
|
public function register(Env $env): void
|
||||||
{
|
{
|
||||||
$env->set('dirsep', \DIRECTORY_SEPARATOR);
|
$env->set('DIRSEP', \DIRECTORY_SEPARATOR);
|
||||||
$env->set('homedir', $_SERVER['HOME'] . \DIRECTORY_SEPARATOR);
|
$env->set('HOME', $_SERVER['HOME'] . \DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
$env->set('wd', new CoreFunc('wd', 'Get the current working directory.', 0, 0,
|
$env->set('wd', new CoreFunc('wd', 'Get the current working directory.', 0, 0,
|
||||||
fn () => getcwd() . \DIRECTORY_SEPARATOR
|
fn () => getcwd() . \DIRECTORY_SEPARATOR
|
||||||
|
@ -10,7 +10,7 @@ class Math implements ILib
|
|||||||
{
|
{
|
||||||
// Constants
|
// Constants
|
||||||
|
|
||||||
$env->set('pi', \M_PI);
|
$env->set('PI', \M_PI);
|
||||||
|
|
||||||
// Basic arithmetic
|
// Basic arithmetic
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class Strings implements ILib
|
|||||||
{
|
{
|
||||||
public function register(Env $env): void
|
public function register(Env $env): void
|
||||||
{
|
{
|
||||||
$env->set('ln', \PHP_EOL);
|
$env->set('EOL', \PHP_EOL);
|
||||||
|
|
||||||
$env->set('trim', new CoreFunc('trim', 'Remove whitespace from beginning and end of string.', 1, 1,
|
$env->set('trim', new CoreFunc('trim', 'Remove whitespace from beginning and end of string.', 1, 1,
|
||||||
fn (string $a) => trim($a)
|
fn (string $a) => trim($a)
|
||||||
|
Loading…
Reference in New Issue
Block a user