All Projects → moevis → lambda-lite-js

moevis / lambda-lite-js

Licence: MIT license
a tiny FUNCITONAL LANGUAGE implemented by javascript. 一个函数式语言,使用 js 实现。

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to lambda-lite-js

website-honestly
🦄 The Red Badger website. Honestly.
Stars: ✭ 26 (-66.23%)
Mutual labels:  lambda
imprenta
An AWS lambda in python 3 that generates PDF files from HTML using jinja, pdfkit and wkhtmltopdf.
Stars: ✭ 18 (-76.62%)
Mutual labels:  lambda
spark-java8
Java 8 and Spark learning through examples
Stars: ✭ 40 (-48.05%)
Mutual labels:  lambda
github-task-manager
receive github hook, notify agent, receive task results, notify github
Stars: ✭ 13 (-83.12%)
Mutual labels:  lambda
Hands-On-Serverless-Applications-with-Go
Hands-On Serverless Applications with Go, published by Packt.
Stars: ✭ 92 (+19.48%)
Mutual labels:  lambda
aws-is-how
Know How Guide and Hands on Guide for AWS
Stars: ✭ 27 (-64.94%)
Mutual labels:  lambda
terraform-aws-lambda-function
A Terraform module for deploying and managing Lambda functions on Amazon Web Services (AWS). https://aws.amazon.com/lambda/
Stars: ✭ 37 (-51.95%)
Mutual labels:  lambda
serverless-image-rendering
Image delivery with AWS Lambda ⚡
Stars: ✭ 43 (-44.16%)
Mutual labels:  lambda
netlify-lambda-function-example
An example Netlify Lambda function that processes payments with Stripe.
Stars: ✭ 93 (+20.78%)
Mutual labels:  lambda
serverless-certificate-creator
serverless plugin to manage the certificate of your lambdas custom domain (API Gateway=
Stars: ✭ 33 (-57.14%)
Mutual labels:  lambda
go-localstack
Go Wrapper for using localstack
Stars: ✭ 56 (-27.27%)
Mutual labels:  lambda
lambdakiq
ActiveJob on SQS & Lambda
Stars: ✭ 131 (+70.13%)
Mutual labels:  lambda
aws-node-custom-user-pool
Serverless AWS Cognito Custom User Pool Example
Stars: ✭ 15 (-80.52%)
Mutual labels:  lambda
shelvery-aws-backups
Automating EBS RDS EC2 backups on lambda
Stars: ✭ 31 (-59.74%)
Mutual labels:  lambda
FancyDialog
Kotlin + DSL风格代替传统的Builder模式 诸多可配置项 高阶函数代替自定义回调接口 书写起来超级顺手
Stars: ✭ 24 (-68.83%)
Mutual labels:  lambda
aws-lambda-scheduler
aws-lambda-scheduler is EventBridge Rule manager that lets you call any existing AWS Lambda Function you have in a set future time with pre-set parameters. Allows more rule creation than AWS limit.
Stars: ✭ 58 (-24.68%)
Mutual labels:  lambda
serverless-lumigo-plugin
Serverless monitoring and troubleshooting plugin to easily apply distributed tracing
Stars: ✭ 59 (-23.38%)
Mutual labels:  lambda
lambda-runtime-pypy3.5
AWS Lambda Runtime for PyPy 3.5
Stars: ✭ 17 (-77.92%)
Mutual labels:  lambda
iot-button-ec2-controller
Allows the start/stop of EC2 instances using an AWS IoT button
Stars: ✭ 23 (-70.13%)
Mutual labels:  lambda
ebs-snapshot-lambda
AWS lambda function to snapshot EBS volumes and purge old snapshots.
Stars: ✭ 37 (-51.95%)
Mutual labels:  lambda

Lambda-Lite-js

a tiny FUNCITONAL LANGUAGE implemented by javascript.

online demo: https://moevis.github.io/lambda-lite-js/ (中文版)

Support

  • Lambda function (including sugar for declearing multi-parameters function)
  • currying, lazy evaluation, recursive in anonymous function (z combinator)
  • Basic pattern matching
  • Point-free style: compose function together with .
  • Basic type system: bool, number, list, function and string.

Tutorial

Lambda function

Using backsplash and arrow to declear an anyoumous function. Lambda function only accept one parameter, but you can use some magic method to break this limit.

\n -> n + 1;
\n -> n * n;
\n -> n + n * n;

Creating function which accepts two parameters.

(\n -> \m -> m + n) 1 2 --- output: 3

Now, declear a function with single-param or multi-params can be write as below:

let add x y = x + y
let result = add 1 2

Pattern matching

Pattern matching is an useful feature in some functional language. The ll language has a basic pattern matching implements.

let func a@1 = a + 1;
let func a@2 = a + 2;
print (func 2);

let echo a@Number = print 'Number';
let echo a@String = print 'String';
let echo a@*      = print 'Other';
echo 'this is string';
echo true;

Pattern matching has some limits in ll.js .

  • The all parameters should be in the same order.
  • The lengths of the functions which have same name also should be equal.
  • Every parameter should have a pattern declearation like Number, String, Boolean, or * for other types.
  • Matching progress is from top to bottom, from left to right.

Various declaration

The keyword let leads an assignment, in forms of let ... = ... (-> ...). The symbol -> is options, only if you want return a value.

let x = 5;
let y = \n -> n + 1;
let z = let a = 3 -> a * a;

Binary condition

The binary condition is in form of if ... then ... else ....

print (if true then 1 else 0)

Native function

now some native functions are accessiable. As well as the basic calculation operators: +-*/.

print "hello";
print (length [1,2,3,4]);
print (reverse [1,2,3,4]);
print [1,2,3,4] !! 2;
print (not true);

Recursive calling

Recursive programming is an elegant programming style.

let fact = \n ->
    if n == 1 then 1
    else n * (fact n - 1);
print (fact 5);

Lambda function can recursive by using z-combinator instead of calling itself.

let z = \f->(\x -> f (\y -> x x y)) (\x -> f (\y -> x x y));
let makeFact = \g -> \n -> if n < 2
    then 1
    else n * (g n - 1);
let fact = z makeFact;
print (fact 5);

Point-free programming

Use . and $ to pretifier your code, less brackets now !!!

Beblow is a sample for calculating (10 + 10) ^ 2

let double = \n -> n + n;
let square = \n -> n * n;
print $ double $ square 10;
let func = double . square;
print $ func 10;

Play with Church Number

let True x y = x;
let False x y = y;
let Zero f x = x;
let One f x = f x;
let Two f x = f (f x);
let Three f x = f (f (f x));
let Add a b f x = a f (b f x);
let Mul a b f x = a (b f) x;

print $ Two (\n -> n + 1) 0;
print $ Add One Two (\n -> n + 1) 0;
print $ Mul Two Three (\n -> n + 1) 0;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].