Giter VIP home page Giter VIP logo

prelude-jxa's People

Contributors

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prelude-jxa's Issues

enumFromThenTo gives incorrect results

prelude-jxa/jsPrelude.js

Lines 1143 to 1153 in 3c93392

// enumFromThenTo :: Int -> Int -> Int -> [Int]
const enumFromThenTo = m =>
// Integer values enumerated from m to n
// with a step defined by (nxt - m).
nxt => n => {
const d = nxt - m;
return Array.from({
length: (Math.floor(n - nxt) / d) + 2
}, (_, i) => m + (d * i));
};

I've just executed

enumFromThenTo(1)(11)(2)

and got

[1]

Missing closing brace in `levels` function.

prelude-jxa/jsPrelude.js

Lines 2400 to 2417 in 6692da1

const levels = tree => {
// A list of lists, grouping the root
// values of each level of the tree.
const go = (a, node) => {
const [h, ...t] = 0 < a.length ? (
a
) : [
[],
[]
];
return [
[node.root, ...h],
...node.nest.slice(0)
.reverse()
.reduce(go, t)
];
};

Do you think go definition could be curried ?

Evaluation of `typeName(null)` gives an error.

prelude-jxa/jsPrelude.js

Lines 4888 to 4912 in 3532094

const typeName = v => {
const t = typeof v;
return "object" === t ? (
Array.isArray(v) ? (
"List"
) : "Date" === v.constructor.name ? (
"Date"
) : null !== v ? (() => {
const ct = v.type;
return Boolean(ct) ? (
(/Tuple\d+/u).test(ct) ? (
"TupleN"
) : ct
) : "Dict";
})() : "Bottom"
) : {
"boolean": "Bool",
"date": "Date",
"number": "Num",
"string": "String",
"function": "(a -> b)"
} [t] || "Bottom";
};

Possible bug in `treeLeaves` ?

prelude-jxa/jsPrelude.js

Lines 4757 to 4764 in 8234535

// treeLeaves :: Tree -> [Tree]
const treeLeaves = tree => {
const subNest = tree.nest;
return (0 < nest.length) ? (
subNest.flatMap(treeLeaves)
) : [tree];
};

I think there is a typo in the following comparison:

(0 < nest.length)

this is so elegant! is there a way to learn how to use this?

for someone who has some generic python scripting experience and attempted to learn functional programming sometimes. i understand Monads at a basic level and think it is a good way to manage error handling. and the idea of declarative programming makes it less error prone.

all this for someone who wants to learn this for its elegance and not for work...

thanks!

Introducing equality for `Date` objects

prelude-jxa/jsPrelude.js

Lines 1199 to 1218 in 3532094

const eq = a =>
// True when a and b are equivalent in the terms
// defined below for their shared data type.
b => {
const t = typeof a;
return t !== typeof b ? (
false
) : "object" !== t ? (
"function" !== t ? (
a === b
) : a.toString() === b.toString()
) : (() => {
const kvs = Object.entries(a);
return kvs.length !== Object.keys(b).length ? (
false
) : kvs.every(([k, v]) => eq(v)(b[k]));
})();
};

Missing application of snd inside `indexedTree`

prelude-jxa/jsPrelude.js

Lines 1951 to 1961 in 5e84ff4

// indexedTree :: Int -> Tree a -> Tree (a, Int)
const indexedTree = rootIndex =>
// A tree in which each root value
// is paired with a top-down
// left-right index, where the root node
// starts at the supplied rootIndex;
mapAccumLTree(
i => x => [1 + i, [x, {
index: i
}]]
)(rootIndex);

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.