ใชใใใฎไฝ่ฒ็ฅญใซๅๅ ใใฆใใใ่ชๅใ25็ตใงใๅบใพใฃใฆๅบงใฃใฆใใใใฉใฟใใชใฉใใใซใใใณใซ่กใฃใฆใใพใฃใใ ๆฎใฃใใฎใฏ่ชๅใๅซใใฆๅไบบใงใๅ ไธไบบใ่ชๅใซ้ฆดใ้ฆดใใใ่ฟๅฏใฃใฆใใใฎใงๆ ใฆใฆ่กใๅ ใใชใ้ใใใ
ๅคใงๅถ็ถ็ฅใๅใใจๅบไผใ็ขบ็ใฏ็ฅใๅใใฎไบบๆฐใซๆฏไพใใใจ่จใใชใใใชใใใใฉใ ๅ ดๆใ ใจใๆ้ใ ใจใใใๆกไปถใไธใใใใใใ็ขบ็ใฏ้ถใๅฃฑใใงใใใใใชๆฐใใใใ
ใธใใชใผใชใผใใ่ฉฆไพๅใใ็บใฎใใกใใใกใใง้ ใใใฆใใใ ใใใใไบบ้ใใใไธญใง่ชๅใ ใใ็ก่ฆใใใฆใใใใใ ใฃใใ ใ ใใใใใใ่ชๅใใไบบใซ่ฉฑใใใใใใจใซใใใใใใใใฐไธๅฟใฏใฟใใชใ่ชๅใฎ็ธๆใใใฆใใใใ
ไฝๅๅธฐใใฎๆๅณใฏใใใใชใใใใฉใใใใ็จใใ ใญใฅใผใฃใฝใไฝใใใผใฟๆง้ ใฎๅ็พใๅฉ็จใใใ ๅน ๅชๅ ๆข็ดขใ
ใใผใ a
ใฎ่กใๅ
ใc a = @ [c1 .. cn]
ใ่ช็ถใซ่ใใใใใใผใฟๆง้ ใซใคใใฆใ (ๆจใจใ) ๆ นใใผใ a0
ใใๅใใฆใๅน
ๅชๅ
ๆข็ดขใง่พฟใฃใ้ ใใชในใใจใใฆ่ฟใใใจใซใใใฐ็ฎ็ใฏๆใใใใใ
bfs a0 = a0 : something
walk (a : rest) = c a ++ walk rest
that is
walk q = c (head q) ++ walk (tail q)
ๅใใใใๅฎๅ
จใชa : rest
ใไธใใใใฆใใฐใ walk
ใจใฏๆ่ฉฎ map
ใซ่ฟใไฝใใ ใใฉใ
queue = a : walk queue
ใใฎใใใซใชในใใฎๅๅธฐ็ๅฎ็พฉใ็จใใใจใ้ใใใจใซใชใใ
walk q = c (head q) ++ walk (tail q)
ใฎไธใง(ใกใใฃใจๆธใใชใใใ)ใ
q = a : walk q
= a : c (head q) ++ walk (tail q)
where
walk (tail q) = c $ head (tail q)
= c $ c $ head q
= c (c a)
q = a ++ c a ++ c (c a) ++ c (c (c a)) ++ ..
ใซใชใใฏใใ (++)
ใ(:)
ใชใใใใ ใฎscan
ใ ใ
q
ใฎๅ
้ ญใใใ้ฉๅฝใชๅฆ็ใใใฆใใฃใฆใ้ฉๅฝใชใจใใงๆใกๅใใฐใ ๅน
ๅชๅ
ๆข็ดขใฏๅฎ้ใใใใ