I'm writing a program in ClojureScript. Here's a function I'm trying to use. (defn…
- User
I'm writing a program in ClojureScript. Here's a function I'm trying to use.
(defn string-list-formatter [items] (if (seq items) (string/join ", " items) "-"))
When I run the output through a str command, I get this: [, ", I, S, 0, 1, 5, ", ,, , ", I, S, M, -, P, ", ,, , ", I, S, 0, 1, 1, ", ,, , ", I, S, 0, 1, 7, ", ,, , ", I, S, 0, 1, 2, ", ,, , ", I, S, 0, 1, 8, ", ,, , ", I, S, 0, 1, 0, ", ,, , ", I, S, 0, 1, 6, ", ,, , ", I, S, 0, 1, 3, ", ]. I want to have just the item names without the brackets and quotes
- Assistant
- User
Without the function, the output appears as ["IS015", "ISM-P", "IS011", "IS017", "IS012", "IS018", "IS010", "IS016", "IS013"] on the webpage. Is there an easy way I can interpret this string as a vector instead?
- Assistant
When you mention that the output looks like on the webpage, it suggests that you're either getting a JSON string that visually represents an array, or it’s being displayed as such by the frontend framework being used. You'll need to first confirm whether this display is a plain string or an actual JavaScript array rendered visually. In any case, you'll want to handle this data appropriately depending on its actual type.