首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
讲解PLC留学生、辅导HTML/web语言、讲解Haskell files 调试C/C++编程|辅导Python程序
PLC: Homework 1 [100 points]
Due date: Wednesday, February 6th
4 extra-credit points if you turn it in by Tuesday, February 5th
About This Homework
For this homework, you will practice writing functions by recursion and pattern-matching in Haskell.
You are free to write helper functions as needed for any problems.
How to Turn In Your Solution
You should create a directory called hw1 (exactly this!) in your personal repository, and add
your Haskell files to this directory. Then push the directory (and all your Haskell files) to your
github.uiowa.edu repop. You should copy the files from the hw1 directory of the course repo to
your own hw1 directory, before you start modifying them. We may release changes to the original
homework files if a bug is reported, for example, so you do not want to modify the original files,
just your copies in the hw1 directory of your personal repo.
As for hw0, you can check that you have submitted correctly by going to github.uiowa.edu in a
web browser and checking that you can see your submitted files in your repo there.
Partners Allowed
You may work by yourself or with one partner (no more). Only one partner should submit the
solution by adding the Haskell files to his/her personal repository. Both partners should submit, in
their hw1 directories, files called partner.txt. Each file contains the hawkid of the other partner.
So if jan and ben are partners, jan should include a partner.txt file that contains just the word
ben. Similarly, ben’s partner.txt file should contain just the word jan. This protocol is to ensure
that both partners agree that they are submitting the solution together. You are free to divide up
the problems and tackle them separately, or to work on problems together.
How To Get Help
You can post questions in the hw1 section on Piazza.
You are also welcome to come to our office hours. See the course’s Google Calendar, linked from
the README.md file of the github.uiowa.edu page for the class, for the locations and times for
office hours.
11 Reading
Read Chapters 3, 4, 5, and 6 of the required book, Programming in Haskell, by Graham Hutton.
2 Basic Problems [42 points]
In the file TableTags.hs is the start of some code dealing with the HTML tags for tables (you can
search online for “html table tags” to find basic background information – but the problems below
do not require this). There are apparently a bunch more tags than the ones we will include below,
but these are the basics.
1. Fill in the definition of the TableTag datatype to give a single constructor for each of the
table tags table, tr, th, and td. The constructor’s name should be the same as the tag
except starting with a capital letter: Table, Tr, Th, Td (because Haskell requires constructor
names to start with a capital letter). [6 points]
2. Fill in the definition of showTableTag to turn TableTags into strings for the tag name. Table
should turn into "Table", etc. You will notice that the code I am providing you already makes
TableTag an instance of the Show class, so TableTags can be printed by ghci, once you define
showTableTage. [6 points]
3. Fill in the definition of equalTableTags to return True when the two input TableTags are
exactly the same (like Tr and Tr), and False otherwise (like Table and Td). [6 points]
4. Fill in the definition of directElt to say which tag is for an entity that can be a direct
component of which other tag [6 points]:
a tr (table row) can be a direct element of a table
a td (table data) can be a direct element of atr
a th (table header) can be a direct element of a tr
a table can be a direct element of a td or th (this is actually allowed, it seems)
that is it: your code should return False for all other pairs
5. Now skip ahead in TableTags.hs just a little for the following, which concern the recursive
datatype TableHtml, intended to represent the HTML for a table:
Implement functions getSubelts, hasTag, and rowLength, according to the descriptions
in the comments above those functions. [6 points each]
3 Intermediate Problems for TableHtml [25 points]
1. Fill in the definition of showTable to turn a TableHtml object into a String. Do not add
any extra spaces or newlines to your output (this is actually easier to code, though it makes
the output pretty hard to read). So for the testTable in Tests.hs, the output should be
2
hi
bye
open
shut
This is worth 10 points.
2. Fill in the definition of tableOk to check that the given TableHtml is really a valid table.
The things you should check are:
The input has Table as its table tag
As you descend into the structure of the table, the pairs of tags you see are allowed by
the directElt function you wrote above.
The rows of the table all have the same length
I found I had to write a couple helper functions for this. The problem is worth 15 points.
You can find some test tables in Tests.hs.
4 Intermediate Problems for SnocLists [21 points]
In SnocLists.hs, you will find a definition of a recursive datatype SList, representing lists where
the head is the second argument and the tail is the first to the Scons constructor (corresponding
to the usual (:) constructor for Haskell’s built-in lists).
1. Fill in the definitions of sappend, slength, and smap, corresponding to (++) (append),
length, and map on Haskell’s built-in lists. Each function is worth 7 points.
5 Challenge Problems [12 points]
1. Fill in the definitions of sfilter, sintersperse, and sconcat in SnocLists.hs, so that
they behave in corresponding manner to the Haskell list operations filter, intersperse,
and concat (see the documentation for these functions on Hoogle). These are worth 2 points
each.
2. In a file called More.hs (which you must create), define a function called descendings which,
given a list of elements of type a where a is in the Ord type class, return a list of lists of a
elements, consisting of the maximal descending subsequences of the input list. For example,
given [100,1,4,2,3,2,1], your function should return [[100,1],[4,2],[3,2,1]]. Getting
the correct type for this (which you should write as part of your code) is worth 2 points, and
the correct code is then 4 more points.
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
辅导 comm2000 creating socia...
2026-01-08
讲解 isen1000 – introductio...
2026-01-08
讲解 cme213 radix sort讲解 c...
2026-01-08
辅导 csc370 database讲解 迭代
2026-01-08
讲解 ca2401 a list of colleg...
2026-01-08
讲解 nfe2140 midi scale play...
2026-01-08
讲解 ca2401 the universal li...
2026-01-08
辅导 engg7302 advanced compu...
2026-01-08
辅导 comp331/557 – class te...
2026-01-08
讲解 soft2412 comp9412 exam辅...
2026-01-08
讲解 scenario # 1 honesty讲解...
2026-01-08
讲解 002499 accounting infor...
2026-01-08
讲解 comp9313 2021t3 project...
2026-01-08
讲解 stat1201 analysis of sc...
2026-01-08
辅导 stat5611: statistical m...
2026-01-08
辅导 mth2010-mth2015 - multi...
2026-01-08
辅导 eeet2387 switched mode ...
2026-01-08
讲解 an online payment servi...
2026-01-08
讲解 textfilter辅导 r语言
2026-01-08
讲解 rutgers ece 434 linux o...
2026-01-08
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!