DEV Community

loading...

Discussion on: Daily Challenge #281 - Area or Perimeter

Collapse
citizen428 profile image
Michael Kohl

A solution in Forth:

: area-or-perimeter 2dup = if * else + 2 * then ;
4 4 area-or-perimeter . 16  ok
6 10 area-or-perimeter . 32  ok