Tech Study

Write a Swift program to rotate the elements of an array of integers to left direction

Introduction

I have used Swift for windows 1.9 for debugging purpose. But you can use any Swift programming language compiler as per your availability.

func rotate_left_3(_ arra: [Int]) -> [Int] {
    var new_arra = arra
      new_arra.removeFirst()
    new_arra.append(arra.first!)
      return new_arra
}
 
print(rotate_left_3([7, 8, 9]))
print(rotate_left_3([-2, 0, 2]))
print(rotate_left_3([0, 20, 0]))

Result

Write a Swift program to rotate the elements of an array of integers to left direction
Write a Swift program to rotate the elements of an array of integers to left direction

TaggedWrite a Swift program to rotate the elements of an array of integers to left direction

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more

Function Pointer in C++

Introduction : Function Pointer in C++ Pointers: In function pointer in c++ are the variables that consist of addresses of …

Read more