AndyM to Concatenative Programming · 1 year agoReverse Vowels | Re: Factorre.factorcode.orgexternal-linkmessage-square1fedilinkarrow-up16arrow-down10
arrow-up16arrow-down1external-linkReverse Vowels | Re: Factorre.factorcode.orgAndyM to Concatenative Programming · 1 year agomessage-square1fedilink
minus-squareAndyOPMlinkfedilinkarrow-up2·1 year agoI solved that problem a little differently: : reverse-vowels-2 ( str -- str' ) [ clone ] [ >lower [ vowel? ] find-all [ values reverse ] [ keys ] bi ] bi ! str vowels idxs [ ! str | vowel idx pick dupd nth ! str | vowel idx orig 1string upper? ! str | vowel idx t/f swapd [ ch>upper ] when ! str | idx vowel set-nth-of ! str' ] 2each ! str' ; Maybe clearer on lemmy without the comments: : reverse-vowels-2 ( str -- str' ) [ clone ] [ >lower [ vowel? ] find-all [ values reverse ] [ keys ] bi ] bi [ pick dupd nth 1string upper? swapd [ ch>upper ] when set-nth-of ] 2each ;
I solved that problem a little differently:
Maybe clearer on lemmy without the comments: