자바 스크립트에서 응용 펑터를 사용하는 방법을 배우려하고 ap
메서드를 발견했습니다. 나는과 같이 세 가지 배열을 결합하여 사용하는 것을 시도하고있다 :Ramda 's ap와 관련없는 어플리케이션 펑터는 무엇입니까?
const products = ['teeshirt', 'sweater']
const options = ['large', 'medium', 'small']
const colors = ['red', 'black']
그래서 documentation마다 나는이 시도하고 같이
const buildMerch = product => option => color =>`${product}-${option}-${color}`
const merchandise = R.ap([buildMerch], [products, options, colors])
을하지만이 다시 세 가지 기능 저를주고있다 :
을[function (option) {
return function (color) {
return product + '-' + option + '-' + color;
};
}, function (option) {
return function (color) {
return product + '-' + option + '-' + color;
};
}, function (option) {
return function (color) {
return product + '-' + option + '-' + color;
};
}]
... 예상 한 배열 조합 결과 대신 ...
["teeshirt- large-red", "teeshirt- large-black", "teeshirt- medium-red", "teeshirt- medium-black", "teeshirt- small-red", "teeshirt- small-black", "sweater- large-red", "sweater- large-black", "sweater- medium-red", "sweater- medium-black", "sweater- small-red", "sweater- small-black"]
내가 뭘 잘못하고 있니? 이 문제를 어떻게 해결할 수 있습니까? https://jsbin.com/fohuriy/14/edit?js,console
좋은 설명, 감사합니다! –