Tag: pattern matching

Write a list comprehension that finds all the Pythagorean triples for right triangles with sides shorter than 100

Write a list comprehension that finds all the Pythagorean triples for right triangles with sides shorter than 100. A Pythagorean triple is three integers a, b, and c, where a² + b² = c². In Elixir it takes a line of code with pattern-matching to produce this. Note the 3

Write a function even_length? that uses pattern matching only to return false if the list you pass it has an odd number of elements, true otherwise.

Write a function even_length? that uses pattern matching only to return false if the list you pass it has an odd number of elements, true otherwise. This is a fun little exercise in Elixir. First we match a single item in the list (odd number) which is false. Then match

Create a website or blog at WordPress.com