再问一个haskell lazy evaluation的问题

10 views
Skip to first unread message

Yuankuns Shi

unread,
Feb 23, 2014, 12:03:08 AM2/23/14
to sh...@googlegroups.com
haskell教程里那个快速排序是这么写的
quicksort :: (Ord a) => [a] -> [a]     
quicksort [] = []     
quicksort (x:xs) =      
    let smallerSorted = quicksort (filter (<=x) xs) 
        biggerSorted = quicksort (filter (>x) xs)    
    in  smallerSorted ++ [x] ++ biggerSorted
我的问题是,两个filter(smaller和bigger)是一次操作呢,还是分两次操作的?谢谢

Yu Changyuan

unread,
Feb 23, 2014, 1:24:55 AM2/23/14
to shlug
两个filter是独立的操作。建议楼主看一下《Parallel and Concurrent Programming in Haskell》第二章的第一节。

http://chimera.labs.oreilly.com/books/1230000000929/ch02.html


--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 shlug+un...@googlegroups.com
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。



--
Best regards,
Changyuan

shi yuankun

unread,
Feb 23, 2014, 7:07:14 AM2/23/14
to sh...@googlegroups.com
谢谢
您收到此邮件是因为您订阅了 Google 网上论坛“Shanghai Linux User Group”中的主题。
要退订此主题,请访问 https://groups.google.com /d/topic/shlug/wYNMYdlSPs4/unsubscribe。
要退订此论坛及其所有主题,请发送电子邮件到 shlug+un...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages