(()=>{ function calculatePrice(brand, productName) { const data = [ ['福人', 800], ['千年舟',…
- User
(()=>{ function calculatePrice(brand, productName) { const data = [ ['福人', 800], ['千年舟', 650], ['兔宝宝', 650], ['莫干山', 650], ['森鹿', 650], ['高度超限', 50], ['深度超限', 100] ]; const entry = data.find(([dataBrand]) => dataBrand.includes(brand)); const basePrice = entry ? entry[1] : 600; return productName.includes("双开") ? basePrice * 1.8 : basePrice; } return calculatePrice([商品品牌],[商品名称]); })(); 为我修改,其中对判断超限的逻辑有问题 因为改数组是用来判断品牌的 ,这个地方应该加一个对名称的判断 我希望你用流式编程 我给你一个案例 你模仿的写 (() => { function calculatePrice(productName, material) { function getWidth(...dimensions) { let sorted = dimensions.slice().sort((a, b) => a - b); return sorted[1]; } const data = [ ['单垭口', '多层', 55], ['单垭口', '欧松', 55], ['单垭口', '颗粒', 45], ['双垭口', '多层', 75], ['双垭口', '欧松', 75], ['双垭口', '颗粒', 65] ]; if (productName.includes("超限")) return Math.ceil((getWidth([加工组长],[加工组宽],[加工组厚])-300)/10)*5; return data .filter(([brand, mat]) => productName.includes(brand) && material.includes(mat)) .map(([, , price]) => price) .concat([0]) // 默认值作为备选 .slice(0, 1)[0]; // 取第一个匹配结果或默认值 } return calculatePrice([商品名称],[商品基材]); })();
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.