2016-09-22 60 views
0

正如你可以在我的Ramda REPL link here看到的,我期待m從最終陣列中刪除。但它仍然存在?爲什麼我的Ramda dropRepeats函數在這裏不起作用?

enter image description here

這裏是R.dropRepeats

const removeRepeats = tickers => { 
    console.log('removeRepeats',tickers); 
    let cleaned = R.dropRepeats(tickers); 
    console.log('cleaned',cleaned); 
    return R.dropRepeats(tickers); 
}; 

let tickers = ['m', 'g', 'j', 'm']; 

let final = removeRepeats(tickers); 

console.log('final', final); 
+2

的文件說,「返回,沒有任何一個新的列表連續重複的元素「,那些'm's不是連續的... – ewcz

+0

大聲笑這是跛腳......嗯,我想我需要繼續尋找另一種方法來完成這些框架之一。 –

+0

@ewcz你想發佈你的答案?順便說一句我在這裏找到了lodash解決方案:https://lodash.com/docs/4.16.1#uniq –

回答

2

R.uniq的醫生可能是你以後的功能:

> R.uniq(['m', 'g', 'j', 'm']) 
['m', 'g', 'j'] 
相關問題