-
Notifications
You must be signed in to change notification settings - Fork 8
Homework2 #9
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
base: main
Are you sure you want to change the base?
Homework2 #9
Conversation
(if (= x y) | ||
(recur | ||
(rest y-seq) | ||
(rest row) | ||
(conj next-row (inc top-left))) | ||
(recur | ||
(rest y-seq) | ||
(rest row) | ||
(conj next-row (max top left)))))))) |
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.
Здесь в обеих ветках используется практически одинаковый вызов recur. Кажется, можно вынести отличающуюся часть третьего аргумента вместе с условием в вышестоящий let и тогда останется один вызов recur.
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.
Могу поправить, если нужно, надо исправлять?
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.
Я думаю, что стоит попробовать! Больше кода напишете (или перепишете) — большему научитесь :)
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.
fixed
(defn common-child-length [fist-string second-string]) | ||
;; Хелпер, который строит следующую строку dynamic programming таблицы по текущей | ||
(defn next-row-helper [x y-seq row] | ||
(loop [y-seq y-seq |
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.
хорошее решение
есть один совет по стилю. это не ошибка, но иногда приводит в замешательство
y-seq
у вас и имя аргумента и имя переменной в цикле
это еще называется variable shadowing - https://en.wikipedia.org/wiki/Variable_shadowing
во многих компаниях это считается не очень хорошим стилем и программисты стараются этого избегать
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.
Приму к сведению - переделывать не вижу смысла сейчас)
|
||
(defn is-palindrome [test-string] | ||
(let [original (str/lower-case | ||
(str/replace test-string #",|!|\?|\.|\s" "")) |
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.
хорошее решение
в этом месте регулярку можно немного упростить
(s/replace (s/lower-case s-not-normal) #"[^a-z]" "")
#"[^a-z]"
сматчится на всё кроме букв
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.
Согласен, я переусложнил. Фиксить не вижу смысла сейчас)
;; Чтение стобцов слева-направо в строку | ||
(defn read-rectangle [rectangle] | ||
(apply str | ||
(loop [result '() |
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.
если список пустой кавычку можно не ставить это специальный случай
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.
Спасибо, приму к сведению, переделывать не вижу смысла сейчас)
complete-slices (partition-all cols-cnt complete-sub-str) | ||
incomplete-slices (partition-all (dec cols-cnt) incomplete-sub-str)] |
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.
тут можно немного упростить если использовать partition
у этой функции есть специальный параметр pad (partition n step pad coll)
элементы которого будут использоваться если не хватает элементов для равных слайсов
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.
Спасибо за замечание - буду иметь в виду, что есть такая функция) Переделывать не вижу смысла сейчас)
Necessary minimum: