How do you include quotation marks in string format?

I need to convert a list A,B,C into “A”,“B”,“C” using concatenate and formula map.

formulamap(list, concatenate(“”“,currentvalue,”“”))

however using concatenate the code recognizes the quotation marks " in the code as a formula. how do I force coda into understanding that the " I am using is to be used and outputed as a string.

HI Kem,

Welcome to Coda and the community!

Here is the solution:

image

And you can use this to force any character in the ASCII code that Coda uses. (As long as it makes sense.)

You can cut and paste from here if you want.

Regards
Rambling Pete

1 Like

hi @Kem_Aldrich ,

Below my contribution

List("C","B","A").WithName(thelist,
  
Sequence(1,thelist.Count()).ForEach(Concatenate('"',thelist.Nth(CurrentValue),'"')))

@Piet_Strydom , ingenious solution, I would have never thought of that!

Cheers, Christiaan

1 Like

That is what I love about Coda, is the different solutions that people come up with.

The simplest would be:

List.ForEach(
  Concatenate('"', CurrentValue, '"')
)

You can use single quotes instead of double quotes to specify a text literal. Also you can escape those special characters by prepending a \, e.g.

"\""

Also you can use Character() like Piet said. Finally, you can use the typographic quotes “” instead of the "programming" ones and you won’t need to escape those — unless you specifically need the “straight” ones.

Christian’s answer is a bit overcomplicated for the cause. In this case there’s no need to iterate over indices and then get elements by Nth() — you can iterate over the list directly. However it’s a valid approach for those cases where you actually need the index, or you need to access both this and previous/next item (you have to use e.g. List.Nth(CurrentValue - 1) for that)

3 Likes

Thank you for all your replies Piet, Christian and Paul! it works perfectly :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.