Logo

Programming-Idioms

History of Idiom 46 > diff from v9 to v10

Edit summary for version 10 by :

Version 9

2015-08-22, 21:07:45

Version 10

2015-09-02, 13:52:19

Idiom #46 Extract beginning of string (prefix)

Create string t consisting in the 5 first characters of string s.

Idiom #46 Extract beginning of string (prefix)

Create string t consisting in the 5 first characters of string s.

Code
t = take 5 s
Comments bubble
The function "take" has two arguments- the number of characters to take as a prefix, and the string to take the prefix from. The function "take" is in the Haskell prelude and doesn't need to be imported.