Code Monkey home page Code Monkey logo

calc's People

Contributors

paulsonkoly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

calc's Issues

debug repl

it would be useful to be able to debug calc with a repl started at a given point in the program. A new built in function repl() would start a repl in the context of the call. When the repl exits the execution of the original script resumes. One can print values of variables and with that debug calc.

As the repl would be a function, it would be running its own frame so variable writes from it would be lost when it returns. Also its return value should be no value error, same as a loop value that never entered the loop body.

string type

It would be useful to support string type.
String operations would be the same as array operations. (indexing and concatenation)

At this point the builtin read function should be re-thought. It probably should just return a string, and we should add builtin functions for type conversions as more built in functions between strings and non strings.

a = read()
a = atoi(a)

user error

It could be useful for the user to create it's own error type. Probably only becomes useful if strings are supported.

New built in function error takes a string (error message) and returns an error.

 f = (n) -> if n == 0 error("whoops") else 10/n

array type

In order to be more useful calc should support array type.

At the minimum array type should have the following concepts:

  • array literal
  • indexing with single index
  • indexing with range
  • array concatenation

The syntax could be whats implied by the following example:

filter = (pred, ary) -> {
  i = 0
  r = []
  while i < #ary {
    if pred(ary@i) r = r + [ary@i] 
    i = i + 1
  }
  r
}

qsort = (ary) -> {
  if #ary == 0 ary else {
    pivot = ary@0
    qsort(filter((n) -> n <= pivot), ary@1:)) + [pivot] + qsort(filter((n) -> n > pivot, ary@1:))
  } 
}

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.