Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
rrobukef
on June 29, 2019
|
parent
|
context
|
favorite
| on:
Programming Patterns I Like
Not a fan of prolog then? As an excercise, find the guard in this snippet (
https://rosettacode.org/wiki/Babbage_problem#Prolog
) and imagine such code in a team codebase!
irjoe
on June 30, 2019
[–]
Quite the opposite :) My preference would be to rely on pattern matching (unification) in the function head:
def transform_data([_|[]]) do: []
I just wanted an example of using guard clauses. It does depend on the actual code though, there's probably a more elixiry solution.
Consider applying for YC's Winter 2027 batch!
Applications
are open till November 2.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: