All Questions
Tagged with swift functional-programming
14 questions
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 ...
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)]
…...
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:
...
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 ...
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 ...
1
vote
1
answer
82
views
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 ...
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 ...
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 ...
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 ...
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, ......
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 ...
1
vote
1
answer
151
views
For Loop with Index to Functional
Trying to simply my code below:
...
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:
...