diff options
author | Juan J. Martinez <jjm@usebox.net> | 2024-05-26 22:20:22 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2024-05-26 22:20:22 +0100 |
commit | 6be7eba8977a719146ffa8c3e9485bc22ec31855 (patch) | |
tree | afb7dcb43c737a0f87b588ccc6a8f2a863eff7bf /examples/sentences.fco | |
parent | cab079eabf46df9a2816e72f2d5132fdba7b5062 (diff) | |
download | funco-6be7eba8977a719146ffa8c3e9485bc22ec31855.tar.gz funco-6be7eba8977a719146ffa8c3e9485bc22ec31855.zip |
Setence type example
Diffstat (limited to 'examples/sentences.fco')
-rw-r--r-- | examples/sentences.fco | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/sentences.fco b/examples/sentences.fco new file mode 100644 index 0000000..ba1c10f --- /dev/null +++ b/examples/sentences.fco @@ -0,0 +1,32 @@ +# See: https://rosettacode.org/wiki/Determine_sentence_type + +def classify(xs) + def sentence_type(s) + def ends_with?(s c) + if =(tail(s) "") + =(s c) + else + @ends_with?(tail(s) c) + end + end + if ends_with?(s "?") + +(s " -> Q") + elif ends_with?(s "!") + +(s " -> E") + elif ends_with?(s ".") + +(s " -> S") + else: + +(s " -> N") + end + end + map(sentence_type xs) +end + +def main() + map(display + classify( + list("Hi there, how are you today?" + "I'd like to present you the washing machine 9001." + "You have been nomiated to win one of these!" + "Just make sure you don't break it"))) +end |