Advertisement
vedranvinko

is_elem?

May 30th, 2015
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.21 KB | None | 0 0
  1. def is_elem? n,list
  2.   return false if list.empty?
  3.   h,*t = list
  4.  
  5.   =begin
  6.   if n == h
  7.     true
  8.   else
  9.     is_elem? n, t
  10.   end
  11.   =end
  12.  
  13.   # replace if/else with
  14.   n == h ? true : is_elem?(n, t)
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement