Occurrence blocks

A feature I’d like to see in Hopscotch is: occurrences, in the same category as character at index and length and stuff

Explanation thingies

nth, first and last occurrences

First occurrence outputs where in a string (by characters) (a) character(s) first appears
Last occurrence output where it last appears
Nth occurrence is like [(5)th occurrence of (aw) in (awawawawawaw)], and n is some number that you choose
If n = 5, it shows the position of the 5th occurrence of aw in awawawawaw, that I think is 8…

Number of occurrences

It outputs the number of time a number/string occurs in a number/string
So in
[Set (sigh) to (number of occurrences of (ll) in (llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch))
Sigh = 5

I’d use it for this type of project: shrug dunno

Here are some examples of Hopscotch code that could be improved if we had this: I dont know :(

Here is an example design I’ve made:

((10)th occurrence of (hi) in (hihihi))
(First occurrence of (hi) in (hihihi))
(Last occurrence of (hi) in (hi oof hi hi)
(Occurrences of (e) in (electogenius))

I’ve seen something similar in another programming languages, it looks like this:

I know it is in JavaScript, not sure about the others


Cool idea – I’d love to see that



Yeah def. it’d make some things a lot more convenient


this would be useful
in css it’s

.element:nth-child(even) {
  // code

This would be interesting. In C it would be:

char * string = "stringymabob";
char * occurrence = "yma";
int i = 0;
int difference = 0;

for(i=0; i<strnlen(string, 1024); i++){
difference = strncmp(occurrence, string, strnlen(occurrence, 1024));
if(0 == difference){

printf("The first occurrence of the string %s in the string %s is at index %d\n", occurrence, string, i);

I’m not sure why I did this.
If you wanted to right bad C (most people do write it like this, I don’t like it), you could put the strncmp in the if statement.


Yeah! Add it. It’s a little confusing, but my pfp is confused so yeah.


Cool, I get it. This would be cool to see.

1 Like

Aaaa you can make arrays with this aaaaa

1 Like

So like
There are three occurrences of eg in (ldrisbtorhfbvtuegfjcbgtufuttbfugobjpegtivhtrbfyfirrofhegfhfhchvu)