All Questions
Tagged with functional-programming ruby
11 questions
2
votes
1
answer
276
views
Ruby Exercise: Implement your own "#group_by" method
Task:
"Implement a method 'gruppiere', in a way that it can be invoked on all enumerable objects (Enumerable). The method receives a block and returns a hash. The items of the enumerable a grouped ...
0
votes
1
answer
140
views
Non-recursive factorial in Ruby
I've implemented a factorial function in a more "Ruby" way. I would like to get feedback on the algorithm.
...
6
votes
3
answers
3k
views
GCD of two numbers in Ruby
I am trying to implement a algorithm for the GCD of two numbers in a functional approach. Can this be improved further, also with regards to performance?
...
11
votes
2
answers
2k
views
Luhn algorithm in Ruby
I'm learning Ruby 2.3 and I've tried to implement a function which performs the Luhn credit card verification algorithm on an input string, returning true if it ...
3
votes
2
answers
352
views
Custom map on `Array`
I have the following problem:
Given an Array, apply a certain method x to each Array ...
5
votes
2
answers
203
views
Print the length of words as input as a histogram with horizontal bars
Input
A list of words separated by any number of spaces.
Output
A horizontal ASCII art histogram, where the n-th line is composed by as many asterisks (*) as the n-...
6
votes
1
answer
157
views
Monoalphatic and Polialphabetic cipher in Ruby
This code encrypts a text with mono-alphabetic and poli-alphabetic substitutions ciphers.
For further info see:
Mono-alphabetic/Caesar Cipher
Poli-alphabetic cipher
...
4
votes
2
answers
196
views
Transforming an array in Ruby
I watched a presentation by Dave Thomas on Elixir where he gave an example problem that he solved using functional programming. He mentioned using Ruby to solve the same problem, but did not show an ...
3
votes
3
answers
222
views
Evaluating a dotted quad IP address has clumsy use of inject/fold
I wrote this to consume valid IPv4 addresses in dotted-quad decimal form:
...
3
votes
3
answers
456
views
Curious fractions in functional Ruby
Problem 33 in Project Euler asks:
The fraction 49/98 is a curious fraction, as an inexperienced
mathematician in attempting to simplify it may incorrectly believe
that 49/98 = 4/8, which is ...
1
vote
1
answer
146
views