Skip to main content
added 373 characters in body
Source Link
marinus
  • 31.2k
  • 7
  • 71
  • 112

APL (88 9)

Update: the old one does not work for strings of different lengths.

{∧/∊⌿↑⍺⍵}
  • ↑⍺⍵: make a matrix with on the first line and on the second line, filling blanks with spaces.
  • ∊⌿: For each column, see if the upper row contains the lower row (as in the old version).
  • ∧/: Take the logical and of all the values.

Old one:

{∧/⍺∊¨⍵}
  • ⍺∊¨⍵: for each combination of elements in and , see if the element from contains the element from . Since in a string these will all be single characters, and a string contains itself, this is basically comparing each pair of characters.
  • ∧/: take the logical and of all the values (if all the characters match, the strings are equal)

APL (8)

{∧/⍺∊¨⍵}
  • ⍺∊¨⍵: for each combination of elements in and , see if the element from contains the element from . Since in a string these will all be single characters, and a string contains itself, this is basically comparing each pair of characters.
  • ∧/: take the logical and of all the values (if all the characters match, the strings are equal)

APL (8 9)

Update: the old one does not work for strings of different lengths.

{∧/∊⌿↑⍺⍵}
  • ↑⍺⍵: make a matrix with on the first line and on the second line, filling blanks with spaces.
  • ∊⌿: For each column, see if the upper row contains the lower row (as in the old version).
  • ∧/: Take the logical and of all the values.

Old one:

{∧/⍺∊¨⍵}
  • ⍺∊¨⍵: for each combination of elements in and , see if the element from contains the element from . Since in a string these will all be single characters, and a string contains itself, this is basically comparing each pair of characters.
  • ∧/: take the logical and of all the values (if all the characters match, the strings are equal)
Source Link
marinus
  • 31.2k
  • 7
  • 71
  • 112

APL (8)

{∧/⍺∊¨⍵}
  • ⍺∊¨⍵: for each combination of elements in and , see if the element from contains the element from . Since in a string these will all be single characters, and a string contains itself, this is basically comparing each pair of characters.
  • ∧/: take the logical and of all the values (if all the characters match, the strings are equal)