-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completed: arrays, fp #40
base: master
Are you sure you want to change the base?
Conversation
тесты в ci не прошли, нужно поправить |
test/bukanin/arrays/solution.rb
Outdated
right = array.size | ||
left = 0 | ||
|
||
loop do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
переписываем на рекурсию
test/bukanin/fp/solution.rb
Outdated
sumstat = 0.0 | ||
counted = 0 | ||
|
||
for idx in 0..(array.size - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
постарайся не использовать for, в реальной жизни он крайне редко используется. тут задачи скорее на map/reduce, можно смело использовать любые стандартные функции из арсенала массива
https://github.com/bbatsov/ruby-style-guide#no-for-loops
test/bukanin/fp/solution.rb
Outdated
def chars_count(films, threshold) | ||
counted = 0 | ||
|
||
for idx in 0..(films.size - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут тоже for нужно заменить
test/bukanin/fp2/solution.rb
Outdated
for elem in self | ||
yield(elem) | ||
end | ||
self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
что вернется в конце функции если не написать тут self?
# Написать свою функцию my_map | ||
def my_map | ||
result = MyArray.new | ||
my_each do |elem| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/bukanin/fp2/solution.rb
Outdated
def my_map | ||
result = MyArray.new | ||
my_each do |elem| | ||
result.append(yield(elem)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не припомню метод append у массива
|
||
def test_my_compact | ||
func = -> (element) { element if element.even? } | ||
func_another = -> (element) { element * @int } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавь ещё вот такой assert
func_yet_another = -> (element) { element.even? }
assert @array.map(&func_yet_another).compact == @my_array.my_map(&func_yet_another).my_compact
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тест не проходит потому что из my_each возвращаются Enumerator'ы с одинаковыми элементами, но разными адресами в памяти
No description provided.