logo
down
shadow

Find out if first letter is a vowel prolog


Find out if first letter is a vowel prolog

By : user2953441
Date : November 20 2020, 01:01 AM
To fix this issue In Prolog you write definite clauses (rules) for predicates. Predicates describe logical relations. For example, you might have a predicate is_vowel/1 which is true if the given argument is a vowel.
code :
is_vowel(Letter):-
    member(Letter, "aeiouAEIOU").
starts_with_vowel(Word):-
    Word = [First|_],
    is_vowel(First).
starts_with_vowel([FirstLetter|_]):-
    is_vowel(FirstLetter).
?- starts_with_vowel("Italy").
true ;
false.

?- starts_with_vowel("Vietnam").
false.

?- Letters = [_|"pple"], starts_with_vowel(Letters), string_to_atom(Letters, Word).
Letters = [97, 112, 112, 108, 101],
Word = apple ;
Letters = [101, 112, 112, 108, 101],
Word = epple ;
Letters = [105, 112, 112, 108, 101],
Word = ipple ...


Share : facebook icon twitter icon
how to remove first letter if it's vowel and return no vowels if there is no vowel

how to remove first letter if it's vowel and return no vowels if there is no vowel


By : vino777
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Write the function startWithVowel(word) that takes in a word as argument and returns a substring that starts with the first vowel found in the word. The function returns 'No vowel' if the word does not contain vowel. , Here is a rather straightforward way to do it:
code :
def startWithVowel(word):
    for i, c in enumerate(word):
        if c.lower() in 'aeiou':
            return word[i:]
    return 'No vowel'

>>> for word in 'apple', 'google', 'xyz', 'BOGGLE':
...     print startWithVowel(word)
apple
oogle
No vowel
OGGLE
What is the query to find emp details whose names contain letter vowel?(oracle database)

What is the query to find emp details whose names contain letter vowel?(oracle database)


By : FaikDjikic
Date : March 29 2020, 07:55 AM
wish help you to fix your issue , You could use REGEXP_LIKE
code :
select * from my_table 
WHERE REGEXP_LIKE (ename, '([aeiou])');
select * from my_table 
WHERE REGEXP_LIKE (ename, '([aeiou])', 'i');
How can I find count of capital letter, small letters and words in Prolog

How can I find count of capital letter, small letters and words in Prolog


By : Reinaldo Morgado
Date : March 29 2020, 07:55 AM
help you fix your problem I need to read a text file and find the number of capital letters, small letters and the number of words. ,
I tested this code using SWI-Prolog on Windows 10.
code :
processChar(end_of_file,[],_) :- !.  % EOF

processChar(CharacterCode,[CharacterCode|CharacterCodes],InputStream) :-
    get_code(InputStream,NextCharacterCode),
    processChar(NextCharacterCode,CharacterCodes,InputStream).

main :-
    open('C:/Users/Eric/Documents/Prolog/test.txt',read,InputStream),
    get_code(InputStream,CharacterCode),
    processChar(CharacterCode,CharacterCodes,InputStream),
    write(CharacterCodes), nl,
    string_codes(Characters,CharacterCodes),
    write(Characters), nl,
    close(InputStream).
main.
[71,114,121,70,102,105,110,100,111,114,46,10,72,117,102,102,76,101,112,117,102,70,46,10,114,97,118,101,110,99,108,97,87,46,10,115,108,121,116,104,101,114,105,78,46]
GryFfindor.
HuffLepufF.
ravenclaW.
slytheriN.
true.
isLower(CharacterCode) :-
    CharacterCode >= 97,
    CharacterCode =< 122.
processChar(...,WordCount,WordCount2) :-
    ...
    WordCount1 is WordCount + 1,
    processChar(...,WordCount1,WordCount2).
processChar(...,WordCount,WordCount2) :-
    ...
    processChar(...,WordCount,WordCount2).
processChar(-1, ... ,WordCount,WordCount1) :-
    WordCount1 is WordCount + 1.
main :-
    ...
    processChar(...,0,WordCount),
    write(WordCount), nl,
    ... .
How to find a 7 letter word without the letter s and contains only one vowel in a word file?

How to find a 7 letter word without the letter s and contains only one vowel in a word file?


By : admn
Date : March 29 2020, 07:55 AM
To fix the issue you can do I am being asked to program a code that will print words from "dictionary.txt" (a 250,000 word file) that contain only one vowel, no letter "s" and is 7 letters long. I know I will have to define a function that opens the file and searches it for those requirements. , No need for regex. Sets are quite fast.
code :
text = open('dictionary.txt').read()

vowels = 'aeiou'
vowelsSet = set(vowels)

for word in text.split():
    word = word.lower()
    if len(word)==7 and not 's' in word and len(set(word)-vowelsSet)==6:
        print (word)
How to find if the first letter of a string is a vowel in javascript

How to find if the first letter of a string is a vowel in javascript


By : user3538183
Date : March 29 2020, 07:55 AM
Hope that helps So I am working on a project and as the title states, I am trying to find if the first letter of a string in javascript is a vowel. So far I have code that looks like this. , You're quite close, just slice the word using [0] and check that way:
code :
function startsWithVowel(word){
   var vowels = ("aeiouAEIOU"); 
   return vowels.indexOf(word[0]) !== -1;
}

console.log("apple ".concat(startsWithVowel("apple") ? "starts with a vowel" : "does not start with a vowel"));
console.log("banana ".concat(startsWithVowel("banana") ? "starts with a vowel" : "does not start with a vowel"));
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org