Git Product home page Git Product logo

telid-lang's Introduction

Telid

Telid is a dynamically-typed, interpreted language

This is a learning project. It's not good. At all.

If I were to go back and do things better, I would:

  • Implement infix notation
  • Use better index access syntax (the only reason it's a prefix operator is because it didn't work as postfix and I didn't want to spend time figuring out why)
  • Figure out the semicolon mess

Example

// this is a comment
/*
  this is a multiline comment
*/

let a = 1; // variables are mutable by default
let const b = 2; // unless you use the const keyword

let fn factorial n =
  if == n 0
    1
  else
    * n factorial(- n 1);

println(factorial(5)); // 120

let y = [1, 2, 3]; // this is an array literal

for i in y {
  println(+ + i ' - ' [- i 1]y); // Index access is a prefix operator
}

let counter = 0;
while <= counter 10 {
  counter = + counter 1;
}
println(counter); // 11

println(* 2 3); // telid uses prefix notation

println(.. 1 10); // .. is the range operator (inclusive, inclusive)
// if you pass a non-integer to .., it will be converted to an integer through truncation

/*

Note: Semicolons are optional, but recommended

Take the following example:

let x = y

(* 2 3)

x would be equal to y(* 2 3), not y, as a first glance might suggest

let x = y;

(* 2 3)

Adding a semicolon would fix this

*/

Look at examples/ for more examples

Global functions

  • println(s): Prints s to stdout
  • print(s): Prints s to stdout without a newline
  • exit(n): Exits the program with exit code n
  • readln(): Reads a line from stdin
  • assert(c): Asserts that c is true
  • parse(s): Parses s as a number and returns void if it fails
  • type(v): Returns the type of v
  • len(v): Returns the length of v
  • filter(a, s): Returns a new array with all elements of a for which type(x) == s
  • concat(a, b): Returns a new array with all elements of a followed by all elements of b

telid-lang's People

Contributors

shreyasm-dev avatar

Watchers

 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.