G'day everyone
(find) is like VBScript's Instr(). What is the equivalent for VBScript's RevInstr() wherein one searches for the first occurrence from the other end of the string? (find (reverse))?
Kind regards,
Bruce.
Quote from: "axtens"
What is the equivalent for VBScript's RevInstr() wherein one searches for the first occurrence from the other end of the string? (find (reverse))?
I think I'll have a go at answering my own question.
(set 'reverse-find
(lambda (findThis inThis)
(- (length inThis) (find (reverse findThis) (reverse inThis)) (length findThis))))
and then some demonstrations plus a comparison of what it finds against what (find) finds.
(set 'toFind "dog")
(set 'sentence "My first dog's fleas are on my second dog's blanket")
(println (slice sentence (reverse-find toFind sentence) (length toFind)))
; "dog"
(println (slice sentence (reverse-find toFind sentence)))
; "dog's blanket"
(println (slice sentence (find toFind sentence)))
; "dog's fleas are on my second dog's blanket"
Am I doing okay so far?
Kind regards,
Bruce.
I don't know VBscript but it looks OK to me.
I think you are progressing quite good. Are you experienced programmer?
Quote from: "Kazimir Majorinc"
I think you are progressing quite good. Are you experienced programmer?
Yes, just not in Lisp. I've been in the IT business in various ways since 1983. At the moment I'm working for The Protium Project (//http) and MyTongue (//http) as a Software/Test Engineer. I program in a variety of languages, including Ada, assembler, (Visual) BASIC, C/C++, Delphi, Fortran, Perl, Protium, Tcl, and VBScript (and a few lesser known languages.)
Kind regards,
Bruce.