



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solutions to the declarative programming techniques test for the cop 4020 programming languages 1 course at the university level. The test includes five questions that require writing iterative functions, functions, and higher-order functions using oz language and tail recursion. The document also includes examples and tests for each question.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




For Grading
{Test {Find [a b c d] a} โ==โ 1} {Test {Find [a b c d] e} โ==โ ~1} {Test {Find [a b c d e f g] c} โ==โ 3} {Test {Find [[99] [86] [12 22] nil [3]] [3]} โ==โ 5} {Test {Find [nil [3]] [3]} โ==โ 2} {Test {Find nil 72} โ==โ ~1} {Test {Find [penn ohio flor iowa] vote} โ==โ ~1}
local FLTemps = {StateTemps 60 90} in {Test {FLTemps nil} โ==โ nil} {Test {FLTemps [60 90 32 72]} โ==โ [60 90 72]} {Test {FLTemps [59 91]} โ==โ nil} {Test {FLTemps [100 95 90 85 80 75 70 65 60 55 50 45 40]} โ==โ [90 85 80 75 70 65 60]} {Test {FLTemps [~2 10 5 91 77 3 77 5 89 89 77]} โ==โ [77 77 89 89 77]} end local IATemps = {StateTemps ~30 100} in {Test {IATemps [60 90 0 ~4 ~30 ~33 32 172]} โ==โ [60 90 0 ~4 ~30 32]} {Test {IATemps [~20 10 5 101 100 3 100 5 89 89 100]} โ==โ [~20 10 5 100 3 100 5 89 89 100]} end {Test {{StateTemps ~50 65} [~51 ~50 60 ~50]} โ==โ [~50 60 ~50]}
{Test {ApplyList [Not Not] true } โ==โ [ false false ]} {Test {ApplyList [ fun {$ X} bread#X#bread end fun {$ X} pita#X#pita end ] turkey} โ==โ [bread#turkey#bread pita#turkey#pita]} {Test {ApplyList nil 33} โ==โ nil} {Test {ApplyList [ fun {$ X} X+1 end ] 4020} โ==โ [4021]} {Test {ApplyList [ fun {$ X} X+1 end fun {$ X} X+2 end ] 4020} โ==โ [4021 4022]} {Test {ApplyList local AddC = fun {$ Y} fun {$ X} X+Y end end in {Map [1 2 3 4 5 2 27 999] AddC} end 1000} โ==โ [1001 1002 1003 1004 1005 1002 1027 1999]}
%% Assume this function in your solution %% NecessarilyTrue : <fun {$