Generate a repeating sequence based on vector

Use each argument: rep(c(1027, 1028, 1030, 1032, 1037), each = 6) # [1] 1027 1027 1027 1027 1027 1027 # [7] 1028 1028 1028 1028 1028 1028 # [13] 1030 1030 1030 1030 1030 1030 # [19] 1032 1032 1032 1032 1032 1032 # [25] 1037 1037 1037 1037 1037 1037 times argument: rep(c(1027, 1028, … Read more

Repeat string to certain length

Jason Scheirer’s answer is correct but could use some more exposition. First off, to repeat a string an integer number of times, you can use overloaded multiplication: >>> ‘abc’ * 7 ‘abcabcabcabcabcabcabc’ So, to repeat a string until it’s at least as long as the length you want, you calculate the appropriate number of repeats … Read more

Do something every x minutes in Swift

var helloWorldTimer = NSTimer.scheduledTimerWithTimeInterval(60.0, target: self, selector: Selector(“sayHello”), userInfo: nil, repeats: true) func sayHello() { NSLog(“hello World”) } Remember to import Foundation. Swift 4: var helloWorldTimer = Timer.scheduledTimer(timeInterval: 60.0, target: self, selector: #selector(ViewController.sayHello), userInfo: nil, repeats: true) @objc func sayHello() { NSLog(“hello World”) }