Re: Generating all permutations of a list in Haskell

看板PLT (程式語言與理論)作者 ( )時間14年前 (2010/06/22 02:11), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《slyfox (klanloss)》之銘言: : I was tracing the code from: : http://shivindap.wordpress.com/2009/01/12/permutations-of-a-list-in-haskell/ : but got confused by: : permutation [1] : = [ 1 : permutation [] ] : = [ 1 : [[]] ] : where did i go wrong? Thanks. permutation [] = [ [] ] permutation xs = [ x:ys | x <- xs, ys <- permutation (delete x xs) ] permutation [1] = [ 1:ys | ys <- permutation [] ] = [ 1:ys | ys <- [ [] ] ] = [ 1:[] ] = [ [1] ] -- And in that line now was a whiskered old man, with a linen cap and a crooked nose, who waited in a place called the Stardust Band Shell to share his part of the secret of heaven: that each affects the other and the other affects the next, and the world is full of stories, but the stories are all one. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 128.36.229.73 ※ 編輯: scwg 來自: 128.36.229.73 (06/22 02:12)

06/22 08:15, , 1F
thx
06/22 08:15, 1F
文章代碼(AID): #1C7wjE4s (PLT)
文章代碼(AID): #1C7wjE4s (PLT)