Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Cocoa
- // creating generic function to find the minimum element from the passed array
- func Search<T:Comparable>(values:[T],element:T)->String{
- var resultFlag = false
- for i in 0..<values.count {
- if(values[i] == element ){
- resultFlag = true
- }
- }
- if resultFlag
- {
- return "Element Found"
- }
- else
- {
- return "Elememt Not Found"
- }
- }
- // call function and passing sample array. Testing 1
- var result = Search(values: [10,20,30], element: 10)
- // displaying result
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement