Skip to content

Commit

Permalink
Added unDigits
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTrew committed Oct 23, 2020
1 parent b581aa5 commit ed031b8
Show file tree
Hide file tree
Showing 494 changed files with 5,864 additions and 5,825 deletions.
20 changes: 10 additions & 10 deletions MD applescript vs javascript/Just.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
```javascript
// Just :: a -> Maybe a
const Just = x => ({
type: 'Maybe',
Nothing: false,
Just: x
});
```


```applescript
-- Just :: a -> Maybe a
on Just(x)
-- Constructor for an inhabited Maybe (option type) value.
-- Wrapper containing the result of a computation.
{type:"Maybe", Nothing:false, Just:x}
end Just
```


```javascript
// Just :: a -> Maybe a
const Just = x => ({
type: 'Maybe',
Nothing: false,
Just: x
});
```
16 changes: 8 additions & 8 deletions MD applescript vs javascript/Left.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
```applescript
-- Left :: a -> Either a b
on |Left|(x)
{type:"Either", |Left|:x, |Right|:missing value}
end |Left|
```


```javascript
// Left :: a -> Either a b
const Left = x => ({
type: 'Either',
Left: x
});
```


```applescript
-- Left :: a -> Either a b
on |Left|(x)
{type:"Either", |Left|:x, |Right|:missing value}
end |Left|
```
16 changes: 8 additions & 8 deletions MD applescript vs javascript/Node.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
```applescript
-- Node :: a -> [Tree a] -> Tree a
on Node(v, xs)
{type:"Node", root:v, nest:xs}
end Node
```


```javascript
// Node :: a -> [Tree a] -> Tree a
const Node = v =>
Expand All @@ -9,12 +17,4 @@ const Node = v =>
root: v,
nest: xs || []
});
```


```applescript
-- Node :: a -> [Tree a] -> Tree a
on Node(v, xs)
{type:"Node", root:v, nest:xs}
end Node
```
18 changes: 9 additions & 9 deletions MD applescript vs javascript/Nothing.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
```javascript
// Nothing :: Maybe a
const Nothing = () => ({
type: 'Maybe',
Nothing: true,
});
```


```applescript
-- Nothing :: Maybe a
on Nothing()
-- Constructor for an empty Maybe (option type) value.
-- Empty wrapper returned where a computation is not possible.
{type: "Maybe", Nothing: true}
end Nothing
```


```javascript
// Nothing :: Maybe a
const Nothing = () => ({
type: 'Maybe',
Nothing: true,
});
```
16 changes: 8 additions & 8 deletions MD applescript vs javascript/Right.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
```applescript
-- Right :: b -> Either a b
on |Right|(x)
{type:"Either", |Left|:missing value, |Right|:x}
end |Right|
```


```javascript
// Right :: b -> Either a b
const Right = x => ({
type: 'Either',
Right: x
});
```


```applescript
-- Right :: b -> Either a b
on |Right|(x)
{type:"Either", |Left|:missing value, |Right|:x}
end |Right|
```
18 changes: 9 additions & 9 deletions MD applescript vs javascript/Tuple.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
```applescript
-- Tuple (,) :: a -> b -> (a, b)
on Tuple(a, b)
-- Constructor for a pair of values, possibly of two different types.
{type:"Tuple", |1|:a, |2|:b, length:2}
end Tuple
```


```javascript
// Tuple (,) :: a -> b -> (a, b)
const Tuple = a =>
Expand All @@ -7,13 +16,4 @@ const Tuple = a =>
'1': b,
length: 2
});
```


```applescript
-- Tuple (,) :: a -> b -> (a, b)
on Tuple(a, b)
-- Constructor for a pair of values, possibly of two different types.
{type:"Tuple", |1|:a, |2|:b, length:2}
end Tuple
```
16 changes: 8 additions & 8 deletions MD applescript vs javascript/Tuple3.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
```applescript
-- Tuple3 (,,) :: a -> b -> c -> (a, b, c)
on Tuple3(x, y, z)
{type:"Tuple3", |1|:x, |2|:y, |3|:z, length:3}
end Tuple3
```


```javascript
// Tuple3 (,,) :: a -> b -> c -> (a, b, c)
const Tuple3 = a => b => c => ({
Expand All @@ -7,12 +15,4 @@ const Tuple3 = a => b => c => ({
'2': c,
length: 3
});
```


```applescript
-- Tuple3 (,,) :: a -> b -> c -> (a, b, c)
on Tuple3(x, y, z)
{type:"Tuple3", |1|:x, |2|:y, |3|:z, length:3}
end Tuple3
```
20 changes: 10 additions & 10 deletions MD applescript vs javascript/TupleN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
```applescript
-- Requires N arguments to be wrapped as one list in AS
-- (the JS version accepts N separate arguments)
-- TupleN :: a -> b ... -> (a, b ... )
on TupleN(argv)
tupleFromList(argv)
end TupleN
```


```javascript
// TupleN :: a -> b ... -> (a, b ... )
function TupleN() {
Expand All @@ -13,14 +23,4 @@ function TupleN() {
})
) : args.reduce((f, x) => f(x), Tuple);
}
```


```applescript
-- Requires N arguments to be wrapped as one list in AS
-- (the JS version accepts N separate arguments)
-- TupleN :: a -> b ... -> (a, b ... )
on TupleN(argv)
tupleFromList(argv)
end TupleN
```
16 changes: 8 additions & 8 deletions MD applescript vs javascript/abs.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
```javascript
// abs :: Num -> Num
const abs =
// Absolute value of a given number - without the sign.
Math.abs;
```


```applescript
-- abs :: Num -> Num
on abs(x)
Expand All @@ -16,4 +8,12 @@ on abs(x)
x
end if
end abs
```


```javascript
// abs :: Num -> Num
const abs =
// Absolute value of a given number - without the sign.
Math.abs;
```
16 changes: 8 additions & 8 deletions MD applescript vs javascript/add.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
```javascript
// add (+) :: Num a => a -> a -> a
const add = a =>
// Curried addition.
b => a + b;
```


```applescript
-- add (+) :: Num a => a -> a -> a
on add(a)
Expand All @@ -16,4 +8,12 @@ on add(a)
end |λ|
end script
end add
```


```javascript
// add (+) :: Num a => a -> a -> a
const add = a =>
// Curried addition.
b => a + b;
```
16 changes: 8 additions & 8 deletions MD applescript vs javascript/all.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
```javascript
// all :: (a -> Bool) -> [a] -> Bool
const all = p =>
// True if p(x) holds for every x in xs.
xs => [...xs].every(p);
```


```applescript
-- all :: (a -> Bool) -> [a] -> Bool
on all(p, xs)
Expand All @@ -18,4 +10,12 @@ on all(p, xs)
true
end tell
end all
```


```javascript
// all :: (a -> Bool) -> [a] -> Bool
const all = p =>
// True if p(x) holds for every x in xs.
xs => [...xs].every(p);
```
18 changes: 9 additions & 9 deletions MD applescript vs javascript/allSame.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
```javascript
// allSame :: [a] -> Bool
const allSame = xs =>
2 > xs.length || (
h => xs.slice(1).every(x => h === x)
)(xs[0]);
```


```applescript
-- allSame :: [a] -> Bool
on allSame(xs)
Expand All @@ -22,4 +13,13 @@ on allSame(xs)
all(p, rest of xs)
end if
end allSame
```


```javascript
// allSame :: [a] -> Bool
const allSame = xs =>
2 > xs.length || (
h => xs.slice(1).every(x => h === x)
)(xs[0]);
```
22 changes: 11 additions & 11 deletions MD applescript vs javascript/allTree.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
```javascript
// allTree :: (a -> Bool) -> Tree a -> Bool
const allTree = p =>
// True if p holds for all nodes of the
// tree to which allTree(p) is applied.
foldTree(
x => xs => p(x) && xs.every(Boolean)
);
```


```applescript
-- allTree :: (a -> Bool) -> Tree a -> Bool
on allTree(p, tree)
Expand All @@ -28,4 +17,15 @@ on allTree(p, tree)
end script
|λ|(tree) of go
end allTree
```


```javascript
// allTree :: (a -> Bool) -> Tree a -> Bool
const allTree = p =>
// True if p holds for all nodes of the
// tree to which allTree(p) is applied.
foldTree(
x => xs => p(x) && xs.every(Boolean)
);
```
16 changes: 8 additions & 8 deletions MD applescript vs javascript/and.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
```javascript
// and :: [Bool] -> Bool
const and = xs =>
// True unless any value in xs is false.
[...xs].every(Boolean);
```


```applescript
-- and :: [Bool] -> Bool
on |and|(xs)
Expand All @@ -15,4 +7,12 @@ on |and|(xs)
end repeat
return true
end |and|
```


```javascript
// and :: [Bool] -> Bool
const and = xs =>
// True unless any value in xs is false.
[...xs].every(Boolean);
```
Loading

0 comments on commit ed031b8

Please sign in to comment.