iOS Swift 2 - Recursion or Iteration [closed] - ios

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
So I've been wondering myself if it's better to use Recursion in Swift or the regular For Loops (iterations in general).
If so in which cases should I choose to use Recursion instead of Iterations.
I know that in some languages one is better/faster than the other, but I'm in doubt about Swift (maybe the same opinion as Objective-C).
If you can give me a solid, or close to, answer I'll be even more thankful.
Thanks in advance, and stay strong in code :)
Cheers.
- IC

This question is a bit general and has many answers already. Regardless, I would always stick with iteration when possible for readability's sake and the fact that it's more efficient than recursion. This is because we often end up solving the same math more than once in recursion. I've also worked with people who discourage the use of recursion in favor of iteration.

Related

Is there a Best Practice for using Streambuilders in Flutter? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I've been reading up on the BloC pattern and there are some really amazing post out there that go into concise and very clear detail on how to use it:
Thomas Burkhart
Didier Boelens
Filip Hracek
Brian Egan
The only problem I've found, is that all the examples I've seen have been fairly simple apps, and I wanted to know if you are building a complex app that has several pages/ screen, how many StreamBuilders are appropriate to have? Granted it doesn't seem like there is an alternative to rebuild a widget using the Bloc pattern beside FutureBuilder, but I assume that there is a cost to have so many streams that are active.

Completion Handlers vs. Delegation when making API Calls [duplicate]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Personally I prefer callback over delegate in Swift for simple logical correlations, because it's pretty straight-forward and easy to understand. At the same time, some prefers delegate, since delegation is a popular pattern in other languages, such as C#.
There are some discussions I found online:
1. "Why you shouldn't use delegates in Swift?"
https://medium.cobeisfresh.com/why-you-shouldn-t-use-delegates-in-swift-7ef808a7f16b#.hqb7zrc1v
2. Apple is shifting its focus more on the callback pattern
https://www.reddit.com/r/swift/comments/2ces1q/closures_vs_delegates/
3. blocks or delegates?
http://blog.stablekernel.com/blocks-or-delegates/
After reading these discussions, I am still undecided on the preference.
I would like to know when is better to use closures and when is better to use delegates? and reasons?
Thanks!
(Opinion based answer for an opinion based question)
The questions shouldn't be which is better, it should be what's the best solution for the problem I'm trying to solve.
My simple rule: if something requires one function as it's interface, a callback is usually a good solution. If more than one function is required, especially when they're required for the basic function of an object, a Delegate is probably a better solution.
As always it depends on the specific situation, but absolute statements rarely work out in real-world usage.

iOS Swift: Closures (Callbacks) versus Delegates, when to use which? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Personally I prefer callback over delegate in Swift for simple logical correlations, because it's pretty straight-forward and easy to understand. At the same time, some prefers delegate, since delegation is a popular pattern in other languages, such as C#.
There are some discussions I found online:
1. "Why you shouldn't use delegates in Swift?"
https://medium.cobeisfresh.com/why-you-shouldn-t-use-delegates-in-swift-7ef808a7f16b#.hqb7zrc1v
2. Apple is shifting its focus more on the callback pattern
https://www.reddit.com/r/swift/comments/2ces1q/closures_vs_delegates/
3. blocks or delegates?
http://blog.stablekernel.com/blocks-or-delegates/
After reading these discussions, I am still undecided on the preference.
I would like to know when is better to use closures and when is better to use delegates? and reasons?
Thanks!
(Opinion based answer for an opinion based question)
The questions shouldn't be which is better, it should be what's the best solution for the problem I'm trying to solve.
My simple rule: if something requires one function as it's interface, a callback is usually a good solution. If more than one function is required, especially when they're required for the basic function of an object, a Delegate is probably a better solution.
As always it depends on the specific situation, but absolute statements rarely work out in real-world usage.

How to write a program that outputs source code [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
This might not be the right place for this to ask, but I am interested in artificial neural networks and want to learn more.
How do you design a network and train it on source code so it can come up with programs for, for example, easy number theory problems?
What's the general name of this research field?
This is a hugely interesting, and very hard, problem area. It will probably take you months to read enough to even understand how to attack the problem. Here's a few things that might help you get started, and they are more to show the problems you will face than to provide solutions:
http://karpathy.github.io/2015/05/21/rnn-effectiveness/
Then read this, and related papers:
https://arxiv.org/pdf/1410.5401v2.pdf
Next, you probably want to read the classic papers in program synthesis and generation at the parse tree/AST level (mostly out of MIT, I think, in the early 90s.)
Best of luck. This is not trivial.

hashes -- Seem like mutant potatoes [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What I have researched about hashes doesn't make them that much clearer to me... what I see is a new [THING] that I cannot see the value in right now. I would RTFM if I could find one worth a beans instead of asking... here is what I was wondering...
I've been looking for answers for a few days now with now avail
Where the heck is a syntax manual for Ruby and further more RoR.
What are these things good for...
I know twitter somehow relies on something of this nature but what is exactly
There's a wealth of information out there, http://ruby-doc.org/core-2.3.0/Hash.html for example is pretty clear on what hashes are.
You need to get your head around some of the basics, there are plenty of tutorials out there, https://www.railstutorial.org/ is one that comes up often, http://guides.rubyonrails.org/getting_started.html is the most obvious place to start.

Resources