Emulate basic Lisp environment in python for educational reasons.
Project description
Lisp Emulator - Version 1.0.2
-----------------------------
About Lisp
--------------
Lisp is a functional programming language, first introduced in
the end of the 1950's, by John Mcarthy, who was a renowned computer
scientist. Since then, many dozens of dialects of lisp have been developed.
The main dialects of nowadays are Common Lisp and Scheme.
About the project
------------------
The project focuses on emulating a very basic environment of an environment
which resembles common-lisp syntax and other compatiable older versions.
All of the code is written in python.
List of all of the basic methods which is introduced in the release:
Side Notes:
-------------
-Lisp is written in a prefix notation, and the code is inside
paranthesis.
- Like Lisp, this implementation isn't case sensitive.
Arithmetic Operators
------------------------
+ , - , * , / - Addition, Subtraction, Multiplication, Division
Those operators can receive an "infinite" number of parameters.
Examples:
>>> ( + 5 6 8 )
19
>>> ( - 8 2 1 )
5
>>> ( + 6 4 ( - 5 2 ) )
13
>>> ( * 7 3 )
21
>>> ( / 6 2 )
3
Output
-----------------
PRINT or WRITE, for example:
>>> ( print "hello" )
"HELLO"
Predicates
---------------------
predicates return a boolean-like value - T ( for true )
, and NIL ( the equivalent of false ).
ZEROP - evaluates to T if the number is 0, else to NIL
EVENP - evaluates to T if the number is odd, else to NIL
ODDP - evaluates to T if the number is even, else to NIL
LESSP - evaluates to T if the first value is smaller than the other
GREATERP - evaluates to T if the first value is bigger than the other
NUMBERP - evaluates to T if the value is a number, else to NIL
STRINGP - evaluates to T if the value is string ( by the double quotation ".." mark )
else, to NIL
Equality Operation
-----------------------------
Equality can be performed via the = operator that can receive
an indefinite number of parameters or the EQ method that receives only 2 parameters.
Those methods return T if all the expressions are equal, else NIL.
Mathematical Operations And Constants
---------------------------
PI Constant - PI is a global constant, and represents
approximately 3.1415926535.
E Constant - E is a global constant, and represents approximately
2.71828182846.
Trigonometric operations - handled in radians
-----------------------------------------------
SIN- receives a parameter and returns its sine
for example:
>>> ( sin ( / PI 2 ) )
1.0
COS - receives a parameter and returns its cosine
TAN - receives a parameter and returns its tangent
ASIN - The reverse operation of SIN.
receives a parameter within range of -1 and 1 and
returns the angle that its sine equals to the parameter (in radians)
ACOS - The reverse operation of COS.
receives a parameter within range of -1 and 1 and
returns the angle that its cosine equals to the parameter (in radians)
ATAN- The reverse operation of TAN.
receives a parameter within range of -1 and 1 and
returns the angle that the result of its tangent operation equals to the parameter (in radians)
SINH - Hyperbolic sine
COSH - Hyperbolic cosine
TANH - Hyperbolic tangent
ASINH - The reverse operation of SINH
ACOSH - The reverse operation of COSH
ATANH - The reverse operation of TANH
Other mathematical operations
----------------------------------
SQRT - receives a parameter and returns its square root
EXPT - receives two parameters and returns the power of the first
parameter by the second.
EXP - receives one parameter and returns the
power of E ( 2.71828182846 ) by that number.
MAX - receives N parameters and return the value of the biggest.
MIN - receives N parameters and return the value of the smallest.
GCD - receives N parameters and returns their Greatest Common
Denominator Operation.
ABS - receives a parameter, and returns its absolute value.
Creating Variables
--------------------------------
You can define new variables via the SET and SETQ methods
( defvar, defparameter are not implemented yet )
for example:
>>> ( setq number 5 )
5
>>> ( + 3 number 4 )
12
Conditionals
---------------------------
Conditions are created via IF expressions
String Operations
--------------------------------------
Concatenate - receives N strings and evaluates to their concatenation.
For example,
DATA TYPES
-----------------------
str - strings. A sequence of characters, sorrounded by double quotes.
for example: "hello" , "world".
int - integers. for example: 6, -3 ,2.
dec - decimal numbers
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lisp_emulator-1.0.3.tar.gz
(14.3 kB
view details)
Built Distribution
File details
Details for the file lisp_emulator-1.0.3.tar.gz
.
File metadata
- Download URL: lisp_emulator-1.0.3.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33b135dd93d49b31ed8ef998a22e6f98c76151e5570767a75230e3bb8805a6aa |
|
MD5 | b4643ffd596213c352f4d745ce8cc84e |
|
BLAKE2b-256 | 7a78d6bc449f933c2b0a81fbe3397e1ae667f87567caf32f0b68d0e4a3c073e6 |
File details
Details for the file lisp_emulator-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: lisp_emulator-1.0.3-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e6489c9680844731ccf460c235568bf5818cbff786762f5942c3427e19658b1 |
|
MD5 | 403e3972f2f66a75677d3f99e828c431 |
|
BLAKE2b-256 | e06f8387eb1f9d2926fb86f0abd0f3dd4702e38935bf407490e53c2805efd48e |