Giter Site home page Giter Site logo

ci_lisp's Introduction

				Comp 232
				CiLisp
				Part 7 & 8

In this part of CiLisp I added support for custom functions as well as letting a function call itself. TO support this I've added several functions including evalCustomFunc, createSymbArgList, createSymbLambda, and fillargs. I've also added extra functions to free memory after each operation. While most of the memory has been freed, there is a few spots I haven't figured out out to free and there's on in particular that seg faults when I attempt to free it (commented out).

Below are sample runs that test the ability to parse and evaluate custom functions as as functions calling themselves. Along with the tests is functions of differing data types.

Since this is the last part of the project I've also included sample runs that include sample code from previous parts so you can see that they're still working as well.

((let (int a 1)(f lambda (x y) (add x y)))(f 2 (f a 3))) ((let (int a 1)(f lambda (x y) (add x y)))(f 2 (f a 3)))

Type: INT Value: 6

((let (double myFunc lambda (x y) (mult (add x 5) (sub y 2)))) (sub (myFunc 3 5) (myFunc 2 3))) ((let (double myFunc lambda (x y) (mult (add x 5) (sub y 2)))) (sub (myFunc 3 5) (myFunc 2 3)))

Type: DOUBLE Value: 17.000000

((let (f lambda (x y) (add x y)))(f (sub 5 2) (mult 2 3))) ((let (f lambda (x y) (add x y)))(f (sub 5 2) (mult 2 3)))

Type: INT Value: 9

((let (double myFunc lambda (x y) (mult (add x 5) (sub y 2)))) (sub (myFunc 3 5) 2)) ((let (double myFunc lambda (x y) (mult (add x 5) (sub y 2)))) (sub (myFunc 3 5) 2))

Type: DOUBLE Value: 22.000000

quit quit

Process finished with exit code 0

((let (int a 1)(double f lambda (x y) (mult x y)))(f 2 (f a 3))) ((let (int a 1)(double f lambda (x y) (mult x y)))(f 2 (f a 3)))

Type: DOUBLE Value: 6.000000

((let (int a 3)(int f lambda (x y) (mult x y)))(f 2 (f a 3))) ((let (int a 3)(int f lambda (x y) (mult x y)))(f 2 (f a 3)))

Type: INT Value: 18

quit quit

/mnt/c/Users/Bombg/CLionProjects/CI_LISP/cmake-build-debug/cilisp

(add 1 2 3 4 5) (add 1 2 3 4 5)

Type: INT Value: 15

(add ((let (abc 1)) (sub 3 abc)) 4) (add ((let (abc 1)) (sub 3 abc)) 4)

Type: INT Value: 6

(add ((let (a ((let (b 2)) (mult b (sqrt 10))))) (div a 2)) ((let (c 5)) (sqrt c))) (add ((let (a ((let (b 2)) (mult b (sqrt 10))))) (div a 2)) ((let (c 5)) (sqrt c)))

Type: INT Value: 5

((let (first (sub 5 1)) (second 2)) (add (pow 2 first) (sqrt second))) ((let (first (sub 5 1)) (second 2)) (add (pow 2 first) (sqrt second)))

Type: INT Value: 17

(add ((let (double a ((let (double b 2)) (mult b (sqrt 10))))) (div a 2)) ((let (double c 5)) (sqrt c))) (add ((let (double a ((let (double b 2)) (mult b (sqrt 10))))) (div a 2)) ((let (double c 5)) (sqrt c)))

Type: DOUBLE Value: 5.236068

((let (int a 1.25))(add a 1)) ((let (int a 1.25))(add a 1)) WARNING: precision loss in the assignment for variable a Type: INT Value: 2 (print 1) (print 1)

Type: INT Value: 1

Type: INT Value: 1

(add 1 2 3 4) (add 1 2 3 4)

Type: INT Value: 10

((let (int a (read)) (double b (read)) (c (read)) (d (read))) (print a b c d)) ((let (int a (read)) (double b (read)) (c (read)) (d (read))) (print a b c d)) read := 1 1 read := 2 2 read := 3 3 read := 4 4

Type: INT Value: 1

Type: DOUBLE Value: 2.000000

Type: INT Value: 3

Type: INT Value: 4

Type: INT Value: 1

quit quit

Process finished with exit code 0

ci_lisp's People

Contributors

bombg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.