Skip to main content
deleted 7 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

 

 
many -> some
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661
lambda :: [String] -> Parser ()
lambda variables =
  do
    char '('
    choice
      [ do
        string "abs "
        name <- manysome $ charBy (`elem` ['a'..'z'])
        guard $ notElem name variables
        char ' '
        lambda (name : variables)
      , do
        string "var "
        choice (map string variables)
        return ()
      , do
        string "app "
        lambda variables
        char ' '
        lambda variables
      ]
    char ')'
    return ()

Try it online!Try it online!

lambda :: [String] -> Parser ()
lambda variables =
  do
    char '('
    choice
      [ do
        string "abs "
        name <- many $ charBy (`elem` ['a'..'z'])
        guard $ notElem name variables
        char ' '
        lambda (name : variables)
      , do
        string "var "
        choice (map string variables)
        return ()
      , do
        string "app "
        lambda variables
        char ' '
        lambda variables
      ]
    char ')'
    return ()

Try it online!

lambda :: [String] -> Parser ()
lambda variables =
  do
    char '('
    choice
      [ do
        string "abs "
        name <- some $ charBy (`elem` ['a'..'z'])
        guard $ notElem name variables
        char ' '
        lambda (name : variables)
      , do
        string "var "
        choice (map string variables)
        return ()
      , do
        string "app "
        lambda variables
        char ' '
        lambda variables
      ]
    char ')'
    return ()

Try it online!

Became Hot Network Question
Tweeted twitter.com/StackCodeGolf/status/1427284026956595203
edited tags
Link
added 16 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661
Loading
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661
Loading