Skip to content

Instantly share code, notes, and snippets.

@oerpli
Last active August 29, 2015 14:20
Show Gist options
  • Save oerpli/4a2b3a22dce05c71592b to your computer and use it in GitHub Desktop.
Save oerpli/4a2b3a22dce05c71592b to your computer and use it in GitHub Desktop.
LEC Clips
(deftemplate person
(slot name)
(slot age)
(slot cantpay
(allowed-symbols yes no)
(default yes))
(slot job
(default unemployed)))
(deftemplate parent
(slot child)
(slot wage)
(slot savings))
(deffacts startup
; no lec, rich parents
(person (name jakob) (age 20))
(parent (child jakob) (wage 200000) (savings 0))
; lec, poor and no to old to get stuff from his parents
(person (name simon) (age 30))
(parent (child simon) (wage 1234521) (savings 132453123))
; lec, poor and no rich parents
(person (name fritz) (age 20))
(parent (child fritz) (wage 10) (savings 0))
; no lec, has job and no difficulties to pay 4 stuff
(person (name peter) (age 30) (job lawyer) (cantpay no))
(parent (child peter) (wage 0) (savings 0))
; lec because he has no parents
(person (name harrypotter) (age 15)))
(defrule getslecyoung
(person (name ?n) (age ?a) (cantpay yes) (job unemployed))
(test (< ?a 25))
(or
(and
(parent (child ?n) (wage ?w) (savings ?s))
(test (< ?w 150000))
(test (< ?s 70000)))
(not
(parent (child ?n) (wage ?) (savings ?))))
=>
(printout t ?n " get's LEC because he's poor and his parent's cant provide for him/don't exist" crlf)
(assert (lec ?n)))
(defrule getslecold
(person (name ?n) (age ?a) (cantpay yes) (job unemployed))
(test (>= ?a 25))
=>
(printout t ?n " get's LEC because he's poor and he's to old to get money from his parents" crlf)
(assert (lec ?n)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment