-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Deyan Totev
committed
Jan 13, 2024
1 parent
118d2b0
commit 5ab014f
Showing
3 changed files
with
44 additions
and
10 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,41 @@ | ||
export function innerJoin(foo, bar) { | ||
if (arguments.length === 1){ | ||
return (_bar) => innerJoin(foo, _bar); | ||
import { curry } from './curry.js' | ||
|
||
function _includesWith( | ||
pred, x, list | ||
){ | ||
let idx = 0 | ||
const len = list.length | ||
|
||
while (idx < len){ | ||
if (pred(x, list[ idx ])) | ||
return true | ||
|
||
idx += 1 | ||
} | ||
|
||
return | ||
} | ||
return false | ||
} | ||
function _filter(fn, list){ | ||
let idx = 0 | ||
const len = list.length | ||
const result = [] | ||
|
||
while (idx < len){ | ||
if (fn(list[ idx ])) | ||
result[ result.length ] = list[ idx ] | ||
|
||
idx += 1 | ||
} | ||
|
||
return result | ||
} | ||
|
||
export function innerJoinFn( | ||
pred, xs, ys | ||
){ | ||
return _filter(x => _includesWith( | ||
pred, x, ys | ||
), xs) | ||
} | ||
|
||
export const innerJoin = curry(innerJoinFn) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import { innerJoin as innerJoinRamda } from 'ramda' | ||
|
||
import { innerJoin } from './innerJoin.js' | ||
|
||
const a = { | ||
|