亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3346 | 回復(fù): 2
打印 上一主題 下一主題

請(qǐng)教 haskell 中的一個(gè)問題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-01-12 18:09 |只看該作者 |倒序?yàn)g覽
1. 統(tǒng)計(jì)一個(gè)文件的行數(shù)
2. 代碼如下:

import IO
   
main = do
        l <- countLineFile "d:/downloads/putstr.hs"
        putStrLn (show l)
       
countLineFile f = do
        h <- openFile f ReadMode
        hCountLines h

hCountLines h = do
        x <- hGetContents h
        return (length (lines x))

請(qǐng)教 hGetContents   代表什么意思?  是句柄 還是函數(shù)??? 謝謝.

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
2 [報(bào)告]
發(fā)表于 2009-01-12 21:31 |只看該作者
原帖由 luckyelement 于 2009-1-12 18:09 發(fā)表
1. 統(tǒng)計(jì)一個(gè)文件的行數(shù)
2. 代碼如下:

import IO
   
main = do
        l  

你可以查一下文檔。
http://haskell.org/hoogle/?hoogle=hGetContents
搜索結(jié)果第二個(gè)鏈接打開:
http://haskell.org/ghc/docs/late ... html#v:hGetContents

  1. hGetContents :: Handle -> IO String

  2. Computation hGetContents hdl returns the list of characters corresponding to the unread portion of the channel or file managed by hdl, which is put into an intermediate state, semi-closed. In this state, hdl is effectively closed, but items are read from hdl on demand and accumulated in a special list returned by hGetContents hdl.

  3. Any operation that fails because a handle is closed, also fails if a handle is semi-closed. The only exception is hClose. A semi-closed handle becomes closed:

  4.     * if hClose is applied to it;
  5.     * if an I/O error occurs when reading an item from the handle;
  6.     * or once the entire contents of the handle has been read.

  7. Once a semi-closed handle becomes closed, the contents of the associated list becomes fixed. The contents of this final list is only partially specified: it will contain at least all the items of the stream that were evaluated prior to the handle becoming closed.

  8. Any I/O errors encountered while a handle is semi-closed are simply discarded.

  9. This operation may fail with:

  10.     * isEOFError if the end of file has been reached.
復(fù)制代碼

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2009-01-13 15:16 |只看該作者
謝謝.
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP