Skip to content

Instantly share code, notes, and snippets.

View juandahurt's full-sized avatar
👋

Juan David Hurtado juandahurt

👋
View GitHub Profile
@juandahurt
juandahurt / recaman.swift
Last active January 17, 2022 03:22
Recaman sequence
// Usage
// recaman(size: 10)
// ouput: [0, 1, 3, 6, 2, 7, 13, 20, 12, 21]
import Foundation
func recaman(size: Int) -> [Int] {
var res = [Int]()
var counter = 1
var currNumber = 0
@juandahurt
juandahurt / DraggableView.swift
Last active March 10, 2021 14:50
Drag and drop in SwiftUI
import SwiftUI
struct DraggableView<Content>: View where Content: View {
var onDrop: () -> Void
var content: Content
@State private var offset: CGSize = .zero
init(onDrop: @escaping () -> Void, content: @escaping () -> Content) {
self.onDrop = onDrop
self.content = content()