Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6744043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:02:13+00:00 2026-05-26T12:02:13+00:00

Given a string ABCDE, how do i find the index of occurrence of another

  • 0

Given a string “ABCDE”, how do i find the index of occurrence of another string “C” in Golfscript?

? operator doesn’t seem to work (http://www.golfscript.com/golfscript/builtin.html#?):

“C” “ABCDE” ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:02:13+00:00Added an answer on May 26, 2026 at 12:02 pm
    "C""ABCDE".,,@`@`{@>1$,<=}++?
    

    There’s no way that "C" "ABCDE" ? would work – if that did a string search, it would be looking for the first occurrence of ABCDE in C.

    However, in GolfScript strings are really a different presentation of arrays of integers. "ABCDE"67? gives 2 because 67 is the Unicode codepoint for C.

    One slightly nicer approach which you might expect to work but doesn’t is (X)

    "C""ABCDE".,,\`{>1$,<}+%\?
    

    This is rather counter-intuitive, but “correct”: ? is an order operation, and string has priority over array. Compare:

    [[1][2][3][4][5]][3]?
    ["1""2""3""4""5"]"3"?
    

    The first gives 2, as expected, but the second gives -1 because the priority of string means that it’s searching for the array inside the string – and no array will ever be equal to an int representing a Unicode codepoint. However, these examples do point the way to another approach of reducing the strings to arrays of ints before using approach X.

    Update

    I sent an e-mail to flagitious suggesting a patch and the latest version of Golfscript has new behaviour for string string ? and string array ?. So if you update, "ABCDE""C"? should give 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the text at http://www.cplusplus.com/reference/string/string/ , string library in C++ is a class,
How to find the below pattern is there or not in a given string
I need to find all substrings from a string that starting with a given
Script given below cuts input string at every occurrence of E and store it
Given a string #abcde#jfdkjfd , how can I get the string between two #
I am trying to generate a unique string/id given another relatively large string(consisting of
I'm trying to compress any given string to a shorter version, copy paste-able compressed
I'm in need to modify a given string to contain only alpha numerical characters,
Possible Duplicate: how to rotate the given string to left or right in C?
I've been looking for a way to hash a given string in C# that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.