2
$\begingroup$

I've imported an Excel with 2 columns (Address and Final Address) which are both urls.

myimport = {{"Address", "Final Address"}, {"http://saliscale.it/news/10-consigli-di-esperti-serramentisti-per- aiutarti-a-scegliere-gli-infissi/", "https://saliscale.it/news/10-consigli-di-esperti-serramentisti-per- aiutarti-a-scegliere-gli-infissi/"}, {"http://www.anekitalia.com/", "https://www.anekitalia.com/"}, {"http://www.bagnochic.com/", "https://www.bagnochic.com/"}} 

Then I defined a pure function to match a List of 2 elements and Mapped it to all the elements of the list:

f[{a_, b_}] := SequenceAlignment[a, b] Map[f, myimport[[All, 1 ;; 2]]] 

Reading this answer I wanted to Apply to each element of the list a second function:

Row[Flatten[ sa /. {a_, b_} :> {Style[a, Red], "(", Style[b, Green], ")"}]] 

sa is defined in the question that I've linked and it's just

sa = SequenceAlignment[text1, text2] 

How can I combine f and the replacement copied from the answer?

$\endgroup$

1 Answer 1

4
$\begingroup$
f[{a_, b_}] := SequenceAlignment[a, b] sa = Map[f, myimport[[All, 1 ;; 2]]]; Row[Flatten[sa /. {a_String, b_String} :> {Style[a, Red], "(", Style[b, Green], ")"}]] 

Specifying the type (String) for a and/or b prevents the replacement applying to the overall lists.

Alternatively, with output as strings:

f[{a_, b_}] := StringJoin[SequenceAlignment[a, b] /. {c_String, d_String} :> {ToString[Style[c, Red], StandardForm], "(", ToString[Style[d, Green], StandardForm], ")"}] Column[Map[f, myimport[[All, 1 ;; 2]]]] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.