I’m making a fake ‘wheel of fortune’ but when a word has multiple same letter(like how ‘happy’ has two p’s) it only works for the first letter and doesn’t sense the second one.
How do I make it so it checks for all the same letters of a word?
Hmm, so, your problem is that you’re using POSITION OF to look for the guessed letter in the word, and it always finds the first one – it doesn’t remember that you’ve looked for one before. But, for example, when you say
then you already know that the position you’re interested in is item 2! There’s no need to call POSITION OF.
But there are better ways to solve this problem using functional programming.
Are you a BJC student? I’m guessing you are because of the tic-tac-toe game you published. If so, you should already be familiar with MAP, KEEP, and COMBINE. You can use MAP to deal with all five letter positions at once. Let’s say the secret word is ROVER, the user has previously guessed O, and the user is now guessing R. Then
gives you a list in which each item is a pair of the known letters from LENGTH and the secret word from RANDOM WORD. So you can say
which says “if this letter of the secret word (ITEM 2) is ANSWER then ANSWER otherwise this letter of what’s already known (ITEM 1)” for each letter pair. So
will update LENGTH the way you want.
By the way, your program will be both more readable and a little faster if in the initialization you say

instead of calling SPLIT a zillion times.
(Also by the way, this game isn’t Wheel of Fortune; it’s Hangman! :~)
Thanks for your reply, but I’m not a BJC student. So I don’t really know what MAP, Keep, and combine does. Still, I think I have an idea how to do this now.
Also, the reason I called this project Wheel of Fortune is because my teacher said this project’s name is Wheel of Fortune (I don’t know why).
Anyways Thank you
Huh. In that case, read Chapter IV of the manual, especially Section IV.D on higher order functions. :~)



