Skip to content

Commit 2b6eaed

Browse files
committed
pluck
1 parent 1f5aff0 commit 2b6eaed

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

basicSyntaxSample/ramda.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: Ping Qixing
33
* @Date: 2017-07-03 08:44:15
44
* @Last Modified by: Ping Qixing
5-
* @Last Modified time: 2017-07-04 13:57:31
5+
* @Last Modified time: 2017-07-04 14:33:12
66
* @Description
77
*/
88
import R from 'ramda';
@@ -126,3 +126,15 @@ console.log(r10);
126126
// or
127127
let r11 = R.into([], R.map(R.add(1)), arr);
128128
console.log(r11);
129+
130+
let basket = [
131+
{item: 'apples', per: 0.95, count: 3, cost: 2.85},
132+
{item: 'peaches', per: 0.80, count: 2, cost: 1.60},
133+
{item: 'plums', per: 0.55, count: 4, cost: 2.20}
134+
];
135+
136+
let add = (a, b) => a + b;
137+
let priceSum = R.reduce(add, 0);
138+
// console.log(R.pluck('cost')(basket));
139+
let totalPrice = R.compose(priceSum, R.pluck('cost'));
140+
console.log(totalPrice(basket));

0 commit comments

Comments
 (0)