問題タブ [lifting]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
1 に答える
503 参照

javascript - 関数を一緒に持ち上げて構成する方法は?

私はこの構造の人々のリストを持っています:

2 つの方法で人を除外したいと思います。友達がいる場合といない場合です。さらに、次のように、の述語持ち上げArray.filterたいと思います。

by次のような関数を明示的に記述することで、この動作を実現できます。

問題:逆が必要な場合は、まったく新しい関数を明示的に記述する必要があります。peopleWithoutFriends

by関数を 2 回書きたくありません。より小さな機能を一緒に構成したいと思います。

質問:

次のような小さな関数を作成して使用するにはどうすればよいですか。flow Booleanget curry notwithFriendswithOutFriendspeople

Repl: https://repl.it/@matthewharwood/ChiefWelloffPaintprogram