The Code
/** * The Arc Challenge is Paul Graham's quest for web framework concision. * * http://www.paulgraham.com/arcchallenge.html * * This is one potential lift-based solution to it using StatefulSnippets. * There are doubtless many other ways. * * @author: Steve Jenson */ class ArcChallenge extends StatefulSnippet { var dispatch: DispatchIt = {case _ => xhtml => ask} /** * Step 1: Type in a Phrase. */ def ask = { <p> Say Anything: {text("", p => phrase = p)} {submit("Submit", () => dispatch = {case _ => xhtml => think})} </p> } /** * Step 2: Show a link that takes you to the Phrase you entered. */ def think = submit("Click here to see what you said", () => dispatch = {case _ => xhtml => answer}) /** * Step 3: Show the phrase. */ def answer = <p>You said: {phrase}</p> private var phrase = "" }