cs 141 final notes

cs 141 final notes - Prolog Info Haskell Info Info Haskell...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Prolog Info Examples of unification A = A : Succeeds ( tautology ) A = B , B = abc : Both A and B are unified with th xyz = C , C = D : Unification is symmetric abc = abc : Unification succeeds abc = xyz : Fails to unify because the atoms are d f ( A ) = f ( B ) : A is unified with B f ( A ) = g ( B ) : Fails because the heads of the terms f ( A ) = f ( B , C ) : Fails to unify because the terms ha meets_prereqs(Taken, [H|T]) :- member(H, Taken), meets_prereqs(Taken, T). /*lists of courses taken by students*/ courses_taken(john, [cs21, cs22, cs23]). courses_taken(sam, [cs21, cs22, cs23]). coursePlanner(Courses) :- complete_list(L), permutation(L, TempListSelection), check_rules(TempListSelection, Courses), Courses = TempListSelection. The Not sign (!) ‘\+’ Haskell Info he atom abc different s are different ave different arity Haskell //example of header module Homework where //end example //basic haskell function center a b c = if ((length a) >= b) then a else (if (((length a) - b) `mod` 2 == 0 else (center ((c : a)) b c)) //example of splitting lists split a = testTuple a [] [] testTuple [] b c = (([], b) : c) testTuple a b c = (testTuple (init a) ((last a
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

cs 141 final notes - Prolog Info Haskell Info Info Haskell...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online