ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Solutions.P04

Description

Some solutions to Problems.P04 of Ninety-Nine Haskell Problems.

Synopsis

Documentation

myLength :: [a] -> Int Source #

Find the number of elements of a list.

Add 1 for each element by induction.

myLength' :: [a] -> Int Source #

Find the number of elements of a list.

Cheat by using length.

myLength'' :: [a] -> Int Source #

Find the number of elements of a list.

Map elements to 1 and return their sum.

myLength''' :: [a] -> Int Source #

Find the number of elements of a list.

Add 1 for each element by induction, but tail recursively.