diff options
| author | Adam Russell <ac.russell@live.com> | 2020-11-29 18:58:16 -0500 |
|---|---|---|
| committer | Adam Russell <ac.russell@live.com> | 2020-11-29 18:58:16 -0500 |
| commit | 4227c63624b68c731b4fdcdf973e0baabee82342 (patch) | |
| tree | d4a67d6bee829af841bcfe18b7a940e324b8885a | |
| parent | bc2bfd2c14e8588ffea19f359e53df55feed1069 (diff) | |
| download | perlweeklychallenge-club-4227c63624b68c731b4fdcdf973e0baabee82342.tar.gz perlweeklychallenge-club-4227c63624b68c731b4fdcdf973e0baabee82342.tar.bz2 perlweeklychallenge-club-4227c63624b68c731b4fdcdf973e0baabee82342.zip | |
cleaned up code
| -rw-r--r-- | challenge-088/adam-russell/prolog/ch-1.p | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/challenge-088/adam-russell/prolog/ch-1.p b/challenge-088/adam-russell/prolog/ch-1.p index ae22b0415c..01922cb3f1 100644 --- a/challenge-088/adam-russell/prolog/ch-1.p +++ b/challenge-088/adam-russell/prolog/ch-1.p @@ -3,12 +3,11 @@ Write a script to return an array @M where $M[i] is the product of all elements of @N except the index $N[i]. */ - +product_a_b(A, B, P):- + P is A*B. list_product([], 1). -list_product([L|Ls], P) :- - foldl(product_, Ls, L, P). - -product_(A, B, P) :- P is A*B. +list_product([H|T], P) :- + foldl(product_a_b, T, H, P). list_products(List, Products):- length(List, L0), |
