Replace individual list elements in Haskell?

Typically, you modify elements of a list by splitting the list, replacing an element, and joining it back together. To split a list at an index, we have: splitAt :: Int -> [a] -> ([a], [a]) which you can use to break up a list, like so: > splitAt 2 [“Off”,”Off”,”Off”,”Off”] ([“Off”,”Off”],[“Off”,”Off”]) now you just … Read more

Looping over a string list

The source of your confusion is probably CMake’s peculiar interpretation of quoted strings. For example, the following all iterate over the list of strings correctly: (1) foreach(LETTER a b c) […] (2) foreach(LETTER a;b;c) […] (3) set(MYLIST “a;b;c”) foreach(LETTER ${MYLIST}) […] The only case where this does not work is (4) foreach(LETTER “a;b;c”) […] The … Read more

Add element to a list In Scala

You are using an immutable list. The operations on the List return a new List. The old List remains unchanged. This can be very useful if another class / method holds a reference to the original collection and is relying on it remaining unchanged. You can either use different named vals as in val myList1 … Read more

Groovy convert from List to var args for method call

Probably the spread operator, *, is what you’re looking for: def to(String… emails) { emails.each { println “Sending email to: $it”} } def emails = [“t@a.com”, “t@b.com”, “t@c.com”] to(*emails) // Output: // Sending email to: t@a.com // Sending email to: t@b.com // Sending email to: t@c.com Notice that the parentheses on the method call to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)