Wikipedia:Reference desk/Archives/Computing/2022 June 6
Appearance
Computing desk | ||
---|---|---|
< June 5 | << May | June | Jul >> | Current desk > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
June 6
[edit]Theory of computation
[edit]Write down the regular expression for a language in which each word begins with an 'a' and ends with 'b' ? 5 marks question — Preceding unsigned comment added by 2409:4054:40C:9398:0:0:CE8:A0B0 (talk) 05:52, 6 June 2022 (UTC)
- Please do your own homework.
- Welcome to Wikipedia. Your question appears to be a homework question. I apologize if this is a misinterpretation, but it is our aim here not to do people's homework for them, but to merely aid them in doing it themselves. Letting someone else do your homework does not help you learn nearly as much as doing it yourself. Please attempt to solve the problem or answer the question yourself first. If you need help with a specific part of your homework, feel free to tell us where you are stuck and ask for help. If you need help grasping the concept of a problem, by all means let us know.-gadfium 06:21, 6 June 2022 (UTC)
- I doubt we will receive these 5 marks if we obey. Also, my tariff for a Theory-of-computation question starts at 5000 marks. --Lambiam 21:34, 6 June 2022 (UTC)
- See Regular expression.
- Here's a handy online regex tester if you need one.
- Words in a language are made of alphabetic characters. Notice the table at Regular expression#Character classes, specifically expression on the row "alphabetic characters" under the column ASCII. That expression will match any one alphabetic character.
- Putting a star * after an expression which matches one character turns it into an expression which matches any number of times, that is, zero or more times. So now you know enough to make a regex which matches words. It won't distinguish between words, it will just match all of them (but not the spaces).
- [Aa] matches the letter a, upper or lower case, and [Bb] does the same for b.
- Stick these things together in some order to possibly win yourself 5 marks, unless they want a more complicated answer which includes spaces and punctuation, in which case the syntax ( ) will be useful. Card Zero (talk) 02:04, 7 June 2022 (UTC)
- One reason we can't do the OP's homework for them is that we don't know the syntax of the r.e. language they have been taught. --Lambiam 06:36, 7 June 2022 (UTC)
- In formal language theory, which this question may be about, an alphabet is any non-empty set of symbols, so the reference to the alphabetic character class may be out of place. --Lambiam 06:46, 7 June 2022 (UTC)
- Additionally, if the answer is meant to be applied to natural language, a 'word' may also be a sequence of letters and digits, too (for example, 'A4' or 'V16'). It may even allow some punctuation (like, say, 'light-year' or 'AK-47'). Then one needs a specific definition what a 'word' is and what can be a word separator. --CiaPan (talk) 15:27, 7 June 2022 (UTC)
- An excellent way to define what a 'word' is, is by giving an r.e. for it. :) --Lambiam 20:15, 7 June 2022 (UTC)}
- Additionally, if the answer is meant to be applied to natural language, a 'word' may also be a sequence of letters and digits, too (for example, 'A4' or 'V16'). It may even allow some punctuation (like, say, 'light-year' or 'AK-47'). Then one needs a specific definition what a 'word' is and what can be a word separator. --CiaPan (talk) 15:27, 7 June 2022 (UTC)