Skip to content

Instantly share code, notes, and snippets.

@indongyoo
Created April 5, 2018 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indongyoo/31be7f5a33ea064deb3c4e8800039cd4 to your computer and use it in GitHub Desktop.
Save indongyoo/31be7f5a33ea064deb3c4e8800039cd4 to your computer and use it in GitHub Desktop.
// 선택된 모든 상품 중 할인 금액이 있는 상품의 총 수량 - pipe 이용
pdts.selected.dq = pipe(
filter(selected),
filter(discount),
_ => pdts.total(quantity, _));
console.log( pdts.selected.dq(products) ); // 5
// 선택된 모든 상품 중 할인 금액이 있는 상품의 총 수량 - pipe + and 이용
pdts.selected.dq = pipe(
filter(and(selected, discount)),
_ => pdts.total(quantity, _));
console.log( pdts.selected.dq(products) ); // 5
// 선택된 모든 상품 중 할인 금액이 없는 상품의 기본 금액 x 수량 뽑기
go(products,
filter(selected),
reject(discount),
pdts.price,
console.log); // 40000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment