How did `find` actually locate a character in a string, when it was passed a string, not a character?












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?










share|improve this question























  • 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.

    – Maciek Łoziński
    Jan 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.

    – Maciek Łoziński
    Jan 19 at 15:30
















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?










share|improve this question























  • 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.

    – Maciek Łoziński
    Jan 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.

    – Maciek Łoziński
    Jan 19 at 15:30














0












0








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?










share|improve this question














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?







red






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 19 at 14:03









Terrence BrannonTerrence Brannon

1,73542448




1,73542448













  • 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.

    – Maciek Łoziński
    Jan 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.

    – Maciek Łoziński
    Jan 19 at 15:30



















  • 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.

    – Maciek Łoziński
    Jan 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.

    – Maciek Łoziński
    Jan 19 at 15:30

















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.

– Maciek Łoziński
Jan 19 at 15:20







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.

– Maciek Łoziński
Jan 19 at 15:20






2




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.

– Maciek Łoziński
Jan 19 at 15:30





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.

– Maciek Łoziński
Jan 19 at 15:30












2 Answers
2






active

oldest

votes


















1















  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.






share|improve this answer

































    1















    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"





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54267883%2fhow-did-find-actually-locate-a-character-in-a-string-when-it-was-passed-a-str%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1















      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.






      share|improve this answer






























        1















        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.






        share|improve this answer




























          1












          1








          1








          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.






          share|improve this answer
















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 19 at 15:14

























          answered Jan 19 at 14:47









          92149214

          35817




          35817

























              1















              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"





              share|improve this answer




























                1















                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"





                share|improve this answer


























                  1












                  1








                  1








                  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"





                  share|improve this answer














                  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"






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 19 at 15:09









                  Maciek ŁozińskiMaciek Łoziński

                  445613




                  445613






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54267883%2fhow-did-find-actually-locate-a-character-in-a-string-when-it-was-passed-a-str%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Liquibase includeAll doesn't find base path

                      How to use setInterval in EJS file?

                      Petrus Granier-Deferre