I\'m trying to get the mean length of fasta sequences using Erlang. A fasta file looks like this
>title1
ATGACTAGCTAGCAGCGATCGACCGTCGTACGC
AT
The call string:len(string:strip(L))
traverses the list at least twice (I'm unaware of the string:strip implementation). Instead you could write a simple function to count the line length w/0 the spaces:
stripped_len(L) ->
stripped_len(L, 0).
stripped_len([$ |L], Len) ->
stripped_len(L, Len);
stripped_len([_C|L], Len) ->
stripped_len(L, Len + 1);
stripped_len([], Len) ->
Len.
The same method can be applied to binaries as well.