<commit_before>\chapter{Anagram Code}

AnagramServer.scala

\begin{verbatim}
object AnagramServer extends EchoApp {
  val WORD = "PASSWORD"
  val ANAGRAM = "<PASSWORD>"

  def setup(args : Array[String]) {	
    val word = Receiver(1996) {
      in =>
        println("Hello")
        ANAGRAM
    }

  	val answers = Receiver(1997) {
  	  in =>
  	    if (in == WORD) {
  	      "That's correct!"
  	    }

  			else {
  			  "Wrong! Try again..."
  			}
  	}
  }
}
\end{verbatim}

Anagram.scala

\begin{verbatim}
object Anagram extends EchoApp {
	  def setup(args : Array[String]) {
		  val sendButton = Button("Send")
		  val field = Field()
		  
		  val anagram = Sender("localhost", 1996, Event("Anagram"))
		  val replies = Sender("localhost", 1997, 
		    field.text.sample(sendButton.click))
		  val messages = replies.errors.map(
		    (t, v) => "Can't connect to server!").merge(replies)

		  val correct = replies.filter(r => r == "That's correct!")<commit_msg>And again<commit_after>\chapter{Anagram Code}

AnagramServer.scala

\begin{verbatim}
object AnagramServer extends EchoApp {
  val WORD = "PASSWORD"
  val ANAGRAM = "<PASSWORD>"

  def setup(args : Array[String]) {	
    val word = Receiver(1996) {
      in =>
        println("Hello")
        ANAGRAM
    }

  	val answers = Receiver(1997) {
  	  in =>
  	    if (in == WORD) {
  	      "That's correct!"
  	    }

  			else {
  			  "Wrong! Try again..."
  			}
  	}
  }
}
\end{verbatim}

Anagram.scala

\begin{verbatim}
object Anagram extends EchoApp {
	  def setup(args : Array[String]) {
		  val sendButton = Button("Send")
		  val field = Field()
		  
		  val anagram = Sender("localhost", 1996, Event("Anagram"))
		  val replies = Sender("localhost", 1997, 
		    field.text.sample(sendButton.click).map((t, tup) => tup._2))
		  val messages = replies.errors.map(
		    (t, v) => "Can't connect to server!").merge(replies)

		  val correct = replies.filter(r => r == "That's correct!")
{'fraction_non_alphanumeric': 0.14438775510204083, 'fraction_numerical': 0.01683673469387755, 'mean_word_length': 2.6247689463955637, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4411308', 'n_tokens_mistral': 793, 'n_tokens_neox': 675, 'n_words': 156}