Created
February 22, 2013 11:46
-
-
Save kanshi/5012914 to your computer and use it in GitHub Desktop.
Thoughtless class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Thoughtless[T <: String]( | |
val sensitivity: Double, | |
val focus: Int, | |
val memory: Memory[T] = Memory[T](Set[Mem[T]]()), | |
val feelings: Feelings = Set[Emotion]()) { | |
def focusScope(ioi: Set[T]): List[T] = ioi.toList.sortWith(_.length < _.length) | |
def teach(ioi: T, emotion: Emotion) = Thoughtless[T]( | |
sensitivity, focus, | |
memory add (Mem[T](ioi, emotion), sensitivity), feelings) | |
def reason(ioi: Set[T], extent: Int = focus): Set[Mem[T]] = | |
if (extent < 1) Set[Mem[T]]() | |
else { | |
val focused = focusScope(ioi) | |
(memory scan (focus - extent + 1, focused.head, sensitivity)) ++ reason(focused.tail.toSet, extent - 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment