Guest User

Untitled

a guest
Jun 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 2.70 KB | None | 0 0
  1. -module(day2).                                                                                                            
  2. -export([test/1]).                                                                                                        
  3.                                                                                                                            
  4. test(Word) ->                                                                                                              
  5.     lists:foldl(match_words, 0, Word).                                                                                    
  6.                                                                                                                            
  7. match_words(Word, Acc) ->                                                                                                  
  8.     Vowels = [$a, $e, $i, $o, $u],                                                                                        
  9.     Closure = fun( X, Acc ) ->                                                                                            
  10.             vowel_match(Word, X, Acc)                                                                                      
  11.         end,                                                                                                              
  12.     lists:foldl(Closure, Acc, Vowels).                                                                                    
  13.                                                                                                                            
  14.                                                                                                                            
  15. vowel_match(Char, Vowel, Acc) ->                                                                                          
  16.     case Char == Vowel of                                                                                                  
  17.         true ->                                                                                                            
  18.             io:format("Test true? Acc: ~p\n", [Acc]),                                                                      
  19.             Acc +1;                                                                                                        
  20.         false ->                                                                                                          
  21.             io:format("Test False? ~p == ~p\n", [Char,Vowel]),                                                            
  22.             Acc                                                                                                            
  23.         end.
Add Comment
Please, Sign In to add comment