SHARE
TWEET

Untitled

a guest Jun 20th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Cocoa
  2.  
  3.  
  4.  
  5. // creating generic function to find the minimum element from the passed array
  6. func Search<T:Comparable>(values:[T],element:T)->String{
  7.     var resultFlag = false
  8.    
  9.     for i in 0..<values.count {
  10.         if(values[i] == element ){
  11.             resultFlag = true
  12.         }
  13.        
  14.     }
  15.    
  16.     if resultFlag
  17.     {
  18.         return "Element Found"
  19.     }
  20.     else
  21.     {
  22.         return "Elememt Not Found"
  23.     }
  24. }
  25.  
  26.  
  27.  
  28. // call function and passing sample array. Testing 1
  29. var result = Search(values: [10,20,30], element: 10)
  30.  
  31. // displaying result
  32. print(result)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top