Skip to content

michirakara/mchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mchain

mchain is a functional language that only uses method chaining and assigning.

Docs

Documentation

Usage

python main.py [path_to_file]

Example

Solution for ABC348-B
examples/abc348-b.mcn

N = nextIn~parseInt();
XY = newList<N, newList<2, 0>> ~map(FUNC<i, i ~map(FUNC<j, nextIn ~parseInt()>)>);
_ = newList<N,0> 
    ~iota(0, 1)
    ~map(FUNC<
        i,
        newList<N,0> 
            ~iota(N ~sub(1), -1) 
            ~reduce(
                newList<2,0>, // [idx, maValue]
                FUNC<
                    a, b, 
                    a ~ifElse(
                        a ~at(1) ~gt(XY ~at(i) ~at(0) ~sub(XY ~at(b) ~at(0)) ~pow(2) ~add(XY~at(i)~at(1) ~ sub(XY ~at(b) ~at(1)) ~pow(2))),
                        FUNC<tmp, tmp>,
                        FUNC<tmp, newList<2,b> ~set(1,XY ~at(i) ~at(0) ~sub(XY ~at(b) ~at(0)) ~pow(2) ~add(XY~at(i)~at(1) ~ sub(XY ~at(b) ~at(1)) ~pow(2)))>,
                    )
                >
            ) ~at(0) ~add(1)
            ~println()
    >);

View more on examples

About

functional language & interpreter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages