Describe what you see when you walk over items

Every step the character takes, describe the entities at that position
excluding the character.
This commit is contained in:
Griffin Smith 2019-09-20 19:38:16 -04:00
parent 4db3a68efe
commit dd16166665
12 changed files with 82 additions and 14 deletions

View file

@ -0,0 +1,15 @@
{-# LANGUAGE ViewPatterns #-}
module Xanthous.Util.Inflection
( toSentence
) where
import Xanthous.Prelude
toSentence :: (MonoFoldable mono, Element mono ~ Text) => mono -> Text
toSentence xs = case reverse . toList $ xs of
[] -> ""
[x] -> x
[b, a] -> a <> " and " <> b
(final : butlast) ->
intercalate ", " (reverse butlast) <> ", and " <> final