Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/prelude/PreludeList/Length.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


module Prelude where

length		:: [a] -> Int 
{-
length (_:xs) 	= 1 + length xs 
length []    	= 0 
-}
length [] = 0				-- need seq to be efficient
length (_:xs) = ll 1 xs
  where
    ll :: Int -> [a] -> Int
    ll a [] = a
    ll a (_:xs) = let a1 = a+1 in a1 `seq` ll a1 xs

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.