Conversation
| (vec (for [line (line-seq f) | ||
| :let [result (zipmap schema (string/split line #"[|]"))] | ||
| :when (if (some? filter-k) | ||
| (string/includes? (get result filter-k nil) filter-v) |
There was a problem hiding this comment.
Just got noticed, that here might be a problem if ID is small and may intersect with others as a same sub-string. Will think about it
There was a problem hiding this comment.
Didn't get your point. You split string by separator read and then it doesn't matter is ID big or small, as I think
There was a problem hiding this comment.
For instance "3" will be caught in ids like "33" "30" and so on. Because "inclides?" will find it as a sub string.
Ivana-
left a comment
There was a problem hiding this comment.
Very good, you included mutability with atoms and some other tricks! Just try to find/google more simple & straightforward solutions when you making some complex & pepeatative parts.
| name | ||
| address | ||
| phoneNumber))] | ||
| (println line))) |
There was a problem hiding this comment.
Discover full magic of destructuring and avoid that complex nested doseq & for with let :)
(defn display-customers
[]
(doseq [{:keys [name address phoneNumber]} (get-customers)]
(println (format "Name: %s, Address: %s, Phone: %s"
name
address
phoneNumber))))
There was a problem hiding this comment.
Hmmm your solution works.... Actually I tried it and it didn't work. Seems that I made another mistake and decided that it is not possible in "for" without "let". Funny =)...
Thanks
| (vec (for [line (line-seq f) | ||
| :let [result (zipmap schema (string/split line #"[|]"))] | ||
| :when (if (some? filter-k) | ||
| (string/includes? (get result filter-k nil) filter-v) |
There was a problem hiding this comment.
Didn't get your point. You split string by separator read and then it doesn't matter is ID big or small, as I think
| (let [customers (into {} | ||
| (for [customer (get-customers) | ||
| :let [{:keys [custID name]} customer]] | ||
| [custID name])) |
There was a problem hiding this comment.
You do know zipmap, I saw it above :)
(let [cs (get-customers)] (zipmap (map :custID cs) (map :name cs)))
But yes, it's a matter of taste
| {name sum})) | ||
| sales-with-default (if (seq sales) sales {"Not found" 0})] | ||
| (doseq [line sales-with-default] | ||
| (println (format "Name: %s, Sum: $%s" (key line) (val line)))))) |
There was a problem hiding this comment.
Again, the power of destructuring (doseq [[k v] sales-with-default] ...
| (clear-screen) | ||
| (doseq [menu ["1. Display Customer Table" "2. Display Product Table" | ||
| "3. Display Sales Table" "4. Total Sales for Customer" | ||
| "5. Total Count for Product" "6. Exit"]] |
There was a problem hiding this comment.
Dude, make it readable, split on different lines :)
"1. ...
"2. ...
...
"
There was a problem hiding this comment.
I don't know. But auto formatter did that
| (defn -main | ||
| [& args] | ||
| (while true | ||
| (condp = (menu) |
There was a problem hiding this comment.
case will look nice here, but it's also a matter of taste
No description provided.