0

I was surprised to note that find "rspq" "q" actually found q in the series. The reason it surprised me is that the string "rpsq" is a series of characters and I expected to have to specify "q" as a character not as a string.

This leads to 2 questions for me: 1. how do I specify the character q in Red? 1. why did the search succeed even though I passed in a string not a character?

Terrence Brannon
  • 4,760
  • 7
  • 42
  • 61
  • You probably expected a functionality of `find`'s `/same` refinement. In documentation (`? find`) you can read: `/same => Use "same?" as comparator.` But strangely, even with `find/same`, result is not what you would expect, despite that `(same? "q" "q") = false`. – Maciej Łoziński Jan 19 '19 at 15:20
  • 2
    Anyway, I think you should not ask two questions at once, and think about keeping your question's title reflect what you ask in the content. – Maciej Łoziński Jan 19 '19 at 15:30

2 Answers2

2
  1. Consult the official reference documentation.
  2. Functions in Red are highly polymorphic. find can either search for a given element or a first occurence of sub-series.
9214
  • 2,105
  • 11
  • 15
2
  1. Characters are values of char! type, and are specified like this: c: #"q".
  2. I'd say it's because Red tries to copy behavior of Rebol. And in Rebol's documentation you can find this example:
probe find "here and now" "and"
"and now"
Maciej Łoziński
  • 812
  • 1
  • 10
  • 16