Created
January 9, 2021 04:16
-
-
Save lmiller1990/bfe3827e77e597cf0713087d6bc8d719 to your computer and use it in GitHub Desktop.
Futuristic functional language for web dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
plugins: [ | |
["@babel/plugin-proposal-pipeline-operator", { "proposal": "fsharp" }], | |
["@babel/plugin-proposal-partial-application"] | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const input = '1, 2, 3, 4 ' | |
const Str = { | |
split: (...args) => String.prototype.split.call(...args), | |
trim: (...args) => String.prototype.trim.call(...args), | |
} | |
const Arr = { | |
map: (...args) => Array.prototype.map.call(...args), | |
reduce: (...args) => Array.prototype.reduce.call(...args), | |
filter: (...args) => Array.prototype.filter.call(...args), | |
join: (...args) => Array.prototype.join.call(...args), | |
length: val => val.length | |
} | |
const Num = { | |
parseInt: (...args) => parseInt(...args) | |
} | |
const toNumber = x => x | |
|> Str.trim | |
|> Num.parseInt | |
const numbers = input | |
|> Str.split(?, ',') | |
|> Arr.map(?, toNumber(?)) | |
const negatives = Arr.filter(numbers, x => x < 0) | |
if (Arr.length(negatives) > 0) { | |
const msg = Arr.join(negatives, ',') | |
throw Error(`No negatives: ${msg}`) | |
} | |
numbers | |
|> Arr.reduce(?, (acc, curr) => acc + curr, 0) | |
|> console.log | |
Math.random() |> console.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"@babel/core": "^7.12.10", | |
"@babel/node": "^7.12.10", | |
"@babel/plugin-proposal-partial-application": "^7.12.1", | |
"@babel/plugin-proposal-pipeline-operator": "^7.12.1", | |
"chokidar": "^3.5.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment