Coder Social home page Coder Social logo

scala-interpreter-'s Introduction

Here is a sample of code that can be run in this interpetor

-> def pi = 3.14
ok
-> def square = lambda (x) x * x
ok
-> 2 * square(pi) 
19.7192
-> def bar = {def x = 1; def foo = lambda (z) z + x; foo}
ok
-> bar(3)
4.0
-> x
Undefined identifier: x
-> def a1 = 2 + 3 * 5
ok
-> a1
17.0
-> def a2 = (2 + 3) * 5
ok
-> a2
25.0
-> a1 == a2
false
-> a1 < a2
true
-> a1 < a2 && true && a1 == a2 && a1 == a3
false
-> a1 == a2 || false || a1 < a2 || a1 == a3
true
-> a1 == a3
Undefined identifier: a3
-> def a3 = if (a1 == a2) a4 else 0
ok
-> a3
0.0
-> a4
Undefined identifier: a4
-> def square = lambda (x) x * x
ok
-> square(3)
9.0
-> def f2c = lambda (ft) {def c = 5 / 9; c * (ft - 32)}
ok
-> f2c(212)
100.0
-> c
Undefined identifier: c
-> def addN = lambda (n) lambda (x) x + n
ok
-> def add6 = addN(6)
ok
-> add6(3)
9.0
-> (lambda (z) 2 * z) (3)
6.0
-> def fact = lambda (n) if (n == 0) 1 else n * fact(n โ€“ 1)
ok
-> fact(5)
120.0
-> def abs = lambda(x) if (x < 0) -1 * x else x
ok
-> abs(-9)
9.0
-> def delta = 100
ok
-> def small = {def delta = 0.00001; lambda(x) abs(x) < delta}
ok
-> small(-0.00000001)
true
-> small(0.001)
false

scala-interpreter-'s People

Contributors

steviewanger avatar

Watchers

 avatar

Forkers

smarbe

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.