Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
1 answer
131 views

Projecteuler.net Problem 2 using collection pipeline Pattern

I solve projecteuler.net Problem 2 deferent way Generate number from 1 to range ex 100 and get the even number Get Fibonacci numbers from list Reduce array I have one problem with a large set of ...
NinjaDeveloper's user avatar
4 votes
2 answers
134 views

Reducing a list of points into a list of pairs of points

I have some data… let points = [(718, 620), (4596, 1280), (410, 333), (4597, 993), (410, 337), (4597, 996), (428, 337), (4597, 1000), (431, 335), (4599, 1044)] …...
dengST30's user avatar
  • 207
2 votes
1 answer
724 views

Finding the most common section from the visible cells in a collection view

My goal is to determine, of all of the currently visible cells in a collection view, which section has the most visible cells. Start by getting the index paths for the visible cells: ...
rmaddy's user avatar
  • 195
1 vote
1 answer
2k views

Numbers as Strings Multiplication Function in Swift

I was solving a problem 20, Factorial Digit Sum, on Project Euler. Factorial Digits Sum \$n!\$ means \$n \cdot (n − 1) \cdot \ldots \cdot 3 \cdot 2 \cdot 1\$ For example, \$10! = 10 \cdot ...
Noah Wilder's user avatar
3 votes
1 answer
230 views

Sorting a list of phone numbers by teleconference provider and location

I'm looking to order an array of phone numbers with a primary sorting criteria of whether the teleconference provider is correct and a secondary criteria of whether the the location of the phone ...
Declan McKenna's user avatar
1 vote
1 answer
82 views

Which swift screen handler approach is better for instantiating a utility class and then presenting a viewController?

1st approach: ...
Honey's user avatar
  • 115
2 votes
1 answer
413 views

Grouping models without dictionary

I want to group an array of structs only using arrays into an array of new structs. In this example I want to group the Person structs by ...
richy's user avatar
  • 133
3 votes
1 answer
88 views

Transformations an array, combination of between map and reduce

I'm working on a function that reduces pairs of elements if they meet some criteria. For example, given an array: ["1", "2", "a", "b", "3", "4"] I want to ...
MathewS's user avatar
  • 653
12 votes
1 answer
369 views

Cat fight (with rockets)

My code is attempting to implement FP in an efficient / readable manner into some of my video games. I realize this may be a bit subjective, but I feel there is enough merit / objectivity to be of ...
Fluidity's user avatar
  • 228
4 votes
1 answer
224 views

Switch expression function

I made a bunch of functions and an enumeration, that together allow me to write something like a switch expression. It's not as powerful as Swift switch statements, since it's lacking pattern matching ...
overactor's user avatar
  • 654
1 vote
1 answer
1k views

Ordered dictionary in swift 2

Loosely basing myself on this blog post, I implemented an ordered dictionary. In essence, it's a wrapper struct for a list of tuples with some initialisers and some functions (map, filter, toArray, ......
overactor's user avatar
  • 654
3 votes
3 answers
879 views

Creating an array of objects for dictionaries

I wrote a piece of code that creates an array of objects based on the array of dictionaries. The problem is that my solution uses multiple loops imperatively. Let's consider the following case. There ...
DCDC's user avatar
  • 233
1 vote
1 answer
151 views

For Loop with Index to Functional

Trying to simply my code below: ...
user1107173's user avatar
7 votes
2 answers
204 views

Defining a simple function-calling operator

I have been writing Swift code for a while and have read a lot of tutorials about how functional paradigms can be applied to Swift. I defined a simple operator: ...
mustafa's user avatar
  • 171