My favorite examples of functional programming in the language Kotlin

One of the great features of Kotlin is that it supports functional programming. Let's look at and discuss some simple but expressive functions written in Kotlin.
 
My favorite examples of functional programming in the language Kotlin
Superset (Boolean)
 
If you studied algebra at a university, you can recall what a superset is. For any set, its superset is the set of all its subsets, including the original set itself and the empty set. For example, if we have the following set:
 
{??3}
 
Then his superset:
 
{{}, {1}, {2}, {3}, {?2}, {?3}, {?3}, {??3}}
 
In algebra such a function is very useful. How do we implement it?
 
If you want to challenge yourself, stop reading ...
+ 0 -

On the formation of sequences in the Collatz conjecture (3n + 1)

On the formation of sequences in the Collatz conjecture (3n + 1)I am attracted by such problems as the Collatz problem. They are simple in the formulation and perfectly train the head, especially algorithmic thinking, which is very useful for the programmer.
 
 
The problem is formulated quite simply:
 
We take any natural number n. If it is even, then divide it by ? and if it is odd, then multiply by 3 and add 1 (we get 3n + 1). Above the number obtained, we perform the same actions, and so on.
 
The Collatz conjecture is that whatever initial number n we take, sooner or later we get unity.
 
 
Algorithmically it looks like this:
 
 
...
+ 0 -

Competition on programming: Trade (intermediate results and announcements)

Many thanks to all the participants of competition on programming !! The decision-making process is not over yet, but at midnight on July 17 we took the set of decisions that was at that time and held a mini-tournament between them. He got 82 decisions.
 
 
But first - a few ads.
 
 

The competition is extended for a week


 
The term for making decisions is extended to July 2? 2018 , 11:59:59 UTC. Also for a week ahead the deadlines are shifted, in which the results of the competition will be announced. We have extended the competition in order to improve coverage during the holiday ...[/h]
+ 0 -

A dimensionless balloon. Utilitarian magic of dimensional analysis

A dimensionless balloon. Utilitarian magic of dimensional analysis  
 
To write this short note I was prompted by a recently published article on Habré The dynamics of the vertical flight of an aircraft is lighter than air . I wanted to write a comment, but it quickly developed into something more and, it seems, more useful.
 
 
In the original article, an example is given of calculating the dynamics of a balloon or an aerostat in the atmosphere. At the same time, air resistance and gradients of atmospheric density and temperature are taken into account, so that the problem reduces to a non-trivial differential equation that can be safely solved numerically by means ...
+ 0 -

Write GUI to 1C RAC, or again about Tcl /Tk

As we understand the theme of the work of 1C-products in the linux environment, one drawback was revealed - the absence of a convenient graphical multiplatform tool for managing the cluster of servers 1C. And it was decided to fix this defect, by writing a GUI for the console utility rac. The language for development was chosen tcl /tk as, in my opinion, the most suitable for this task. And now, I want to present some interesting aspects of the solution in this material.
 
Write GUI to 1C RAC, or again about Tcl /Tk
 
 
The ...
+ 0 -

Competition on programming: Trade (announcement)

Advertisements for members competition on programming .
 
 

The order of final testing is


 
Initially, we wanted to hold a tournament on the principle of "everyone with everyone." However, several participants announced their intention to submit to the competition a lot of weak decisions - the "spoilers" against which the main decision of the participant plays well, or they expressed fears that others will do the same. Such actions are clearly prohibited by the rules, but even if the rules somehow get around, this is contrary to the spirit of the competition. This is a contest about who ...[/h]
+ 0 -

Cross-functional, dependency manager, monitoring in iOS and UI-tests. How was Avito iOS Summer Edition

On June 1? we held a traditional meeting Avito iOS Summer Edition. For discussion on the topic, four themes were chosen: UI-testing, work in cross-functional commands, monitoring in mobile applications, history and insides of its own dependency manager. In case you could not come to the Mitap, did not follow the broadcast on YouTube or just want to learn something new - we share photos, videos, presentations from the meeting and feedback from listeners.
 
Cross-functional, dependency manager, monitoring in iOS and UI-tests. How was Avito iOS Summer Edition Presentation
 
Comments of the listeners
 
 
Considered the advantages of working in cross-functional teams. It is clear why such a transformation ...
+ 0 -

Thinking in the style of Ramda: Conclusion

1. The first steps are
 
2. We combine the functions
 
3. Partial application (currying)
 
4. Declarative programming
 
5. Lossless notation
 
6. Indestructibility and objects
 
7. Indestructibility and arrays
 
8. Lenses
 
9. Conclusion
 
10. Using Ramda with Redux
 
11. Functional components with React stateless functions and Ramda
 
12. Modular producers and selectors
 
This post completes a series of articles on functional programming called "Ramda-style thinking."
 
In t...
+ 0 -

TRIZ, Haskell and functional thinking

At the word TRIZ, one often recalls the thesis "an ideal system is one that does not exist (and its function is fulfilled in this case)." As a good administrator, who does not appear in the office, but everything is working at the same time.
 
The function and system are critical concepts in TRIZ, they even speak about the functional style of thinking. True, with these words, I personally have an association with functional programming languages.
 
Let's try to see how organically the ideas of functional thinking of TRIZ are displayed on Haskell, one pure functional languages ​​of general purpose.
 
TRIZ, Haskell and functional thinking
 
Function
 
Function
- mod...
+ 0 -

Programming Contest: Trade

Programming Contest: TradeCompany Hola again announces a competition for programming! Winners are expected to receive prizes:
 
 
 
First place: 3000 USD.
 
Second place: 2000 USD.
 
Third place: 1000 USD.
 
The jury may award at its discretion a special prize of 400 USD.
 
If you send someone a link to this contest, putting our address is in CC, and this person will take the prize place, you will receive half of the prize amount (of course, not to the detriment of the winner's award). For one winner, only one person can receive such an award - the one who sent the link first.
 
 
Authors of interesting solutions ...
+ 0 -