Skip to content

Comments

Home Work 2 Boriskin#18

Open
boriskinay wants to merge 3 commits intoClojure-Developer:mainfrom
boriskinay:HW-1-2
Open

Home Work 2 Boriskin#18
boriskinay wants to merge 3 commits intoClojure-Developer:mainfrom
boriskinay:HW-1-2

Conversation

@boriskinay
Copy link

No description provided.


(defn is-palindrome
[test-string]
(as-> test-string p

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хороший подход. решение верное 👍
Вы заметили что переменная p всё время выступает в качестве последнего аргумента? Можно воспользоваться ->> макросом! он как раз помещает результат в нужное место


(defn is-pangram
[test-string]
(as-> test-string p

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как и в примере с палиндромом можно брать ->>

[test-string]
(as-> test-string p
(re-seq #"[\w+]" p)
(string/join "" p)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

такой вопрос - а зачем джойнить список обратно в строку? списки и вектора можно сравнивать напрямую

(string/lower-case p)
(re-seq #"[\w+]" p)
(set p)
(string/join "" p)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут джойн в строку тоже выглядит как лишняя операция

(defn combinations
"Ищем все возможные комбинации потомков в сторке с учетом порядка следования букв"
[letters]
(loop [result nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот тут не совсем понятка задумка. зачем тут loop? в теле нет вызова recur значит итерации не будет. вместо этого используется рекурсия

(if (empty? rest-result)
#{result}
(let [current (first rest-result)
next-result (conj result current)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это похоже не используется?

(defn delete-not-repeat-letter
"Удаляем не повторяющиеся буквы в двух строках"
[first-string second-string]
(filterv identity

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter identity обычно можно заменить на вызов функции remove

s2-not-repeat (delete-not-repeat-letter s2 s1)]
(reduce max
(map count
(some-> (intersection (combinations s1-not-repeat) (combinations s2-not-repeat)))))))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а для чего используется some-> ? кажется лишним

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants