Git Product home page Git Product logo

arch's Introduction

Arch

Arch is a stack based functional programming language based on combinatory logic.

Prerequisites

  • Java 11+
  • Gradle

Getting Started

You can start an interactive REPL session with

./gradlew run --console=plain

Language

module base

import symbols ( foo, bar );

let y = 10 ;
let z = 20 ;

private let double :: int -> int = 2 * ;

let bar :: string int -> [string] =
  [ ] [dip] i [swap] push pop rot over2
;

let main = double bar foo read

Type system

TBD

let gcd :: int int -> int [int] =
  { }
;

Variables and functions

You can assign a value to a name using the let statement.

let x = 10 ;

Given that arch is a stack based language a function is just a series of operations assigned to a name. As such, functions are defined in exactly the same way as variables are.

let double = 2 * ;

Operations

operator

id      :  ->
Identity function, does nothing.
Any program of the form  P id Q  is equivalent to just  P Q.

dup      :   X  ->   X X
Pushes an extra copy of X onto stack.

swap      :   X Y  ->   Y X
Interchanges X and Y on top of the stack.

rollup      :  X Y Z  ->  Z X Y
Moves X and Y up, moves Z down

rolldown      :  X Y Z  ->  Y Z X
Moves Y and Z down, moves X up

rotate      :  X Y Z  ->  Z Y X
Interchanges X and Z

popd      :  Y Z  ->  Z
As if defined by:   popd  ==  [pop] dip

dupd      :  Y Z  ->  Y Y Z
As if defined by:   dupd  ==  [dup] dip

swapd      :  X Y Z  ->  Y X Z
As if defined by:   swapd  ==  [swap] dip

rollupd      :  X Y Z W  ->  Z X Y W
As if defined by:   rollupd  ==  [rollup] dip

rolldownd      :  X Y Z W  ->  Y Z X W
As if defined by:   rolldownd  ==  [rolldown] dip

rotated      :  X Y Z W  ->  Z Y X W
As if defined by:   rotated  ==  [rotate] dip

pop      :   X  ->
Removes X from top of the stack.

choice      :  B T F  ->  X
If B is true, then X = T else X = F.

or      :  X Y  ->  Z
Z is the union of sets X and Y, logical disjunction for truth values.

xor      :  X Y  ->  Z
Z is the symmetric difference of sets X and Y,
logical exclusive disjunction for truth values.

and      :  X Y  ->  Z
Z is the intersection of sets X and Y, logical conjunction for truth values.

not      :  X  ->  Y
Y is the complement of set X, logical negation for truth values.

+      :  M I  ->  N
Numeric N is the result of adding integer I to numeric M.
Also supports float.

-      :  M I  ->  N
Numeric N is the result of subtracting integer I from numeric M.
Also supports float.

*      :  I J  ->  K
Integer K is the product of integers I and J.  Also supports float.

/      :  I J  ->  K
Integer K is the (rounded) ratio of integers I and J.  Also supports float.

rem      :  I J  ->  K
Integer K is the remainder of dividing I by J.  Also supports float.

div      :  I J  ->  K L
Integers K and L are the quotient and remainder of dividing I by J.

sign      :  N1  ->  N2
Integer N2 is the sign (-1 or 0 or +1) of integer N1,
or float N2 is the sign (-1.0 or 0.0 or 1.0) of float N1.

neg      :  I  ->  J
Integer J is the negative of integer I.  Also supports float.

ord      :  C  ->  I

arch's People

Contributors

owainlewis avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.