当前位置: 中原健康网 -> 新闻资讯

Haskell留学生代写、代做Java/c++程序语言、代写extens

时间:2020-11-27 16:31    来源: 中原健康网   作者:先轸 阅读量:16771   会员投稿

Haskell留学生代写、代做Java/c++程序语言、代写extension

Haskell Coursework 2018

November 27, 2018

1 Introduction

The Haskell coursework for this year is a programming challenge. This challenge

is modular: it is not necessary to complete every aspect to get a passing mark.

If a function is marked as being higher order, it should written using higher

order functions. Submit a Haskell file (extension *.hs). This file must load into

ghci without type or other errors. You must provide type signatures for all

defined functions. Finally, while it is acceptable to use functions provided by

Prelude, please write any other required functions yourself. Do not use functions

imported from libraries. While this is bad practice for real development, it is

good practice for learning.

2 Basics

A Horse is an ascii image of a horse. Learn about newtypes (via Google) and

instantiate a Horse type with at least one member, e.g.

h o r s e : : Horse

h o r s e = [ ” , / / ) ”

, ” ; ; ’ ”

, ” , ; ; ’ ( ’ ”

, ” / ’ ) ” ]

3 Rotations

Define a higher order function, transpose that takes a Horse and rotates it

90

to the right. Define another (higher order) function mirror which flips the

Horse on its vertical access. Show that it is possible to perform all possible

rotatations using just these two functions (hint: think compositionally).

1

4 Integer Sequences

Define functions to generate two mathematical sequences, such as the Fibonacci

sequence. These should be higher order functions. Hint: you may want to

look at the On-Line Encyclopedia of Integer Sequences https://oeis.org/ for

inspiration. You might want to make sure that the sequences do not grow too

quickly. Note: do not use the Fibonacci sequence!

As such sequences may be infinite, it should be possible to pass a parameter

to the functions to limit the length of the returned list.

5 IO

Write a function pretty :: Horse > IO () which takes an element of type

Horse and prints it to the terminal.

Write a function horseSeq which takes a function f, a positive integer n and

a Horse as an argument and pretty prints Horses in accordance with f, e.g.

h o r seSe q : : ( Int > [ Int ] ) > Int > Horse > IO ( )

h o r seSe q f n h = . . .

h o r seSe q f i b o n a c c i 5 h o r s e =

 no h o r s e

, / / )

; ; ’

, ; ; ’ ( ’

/ ’ )

, / / )

; ; ’

, ; ; ’ ( ’

/ ’ )

, / / ) , / / )

; ; ’ ; ; ’

, ; ; ’ ( ’ , ; ; ’ ( ’

/ ’ ) / ’ )

, / / ) , / / ) , / / )

; ; ’ ; ; ’ ; ; ’

, ; ; ’ ( ’ , ; ; ’ ( ’ , ; ; ’ ( ’

/ ’ ) / ’ ) / ’ )

6 Type Classes

What typeclass(es) does Horse belong to? Write at least one typeclass instance

for Horse.

如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp

郑重声明:此文内容为本网站转载企业宣传资讯,目的在于传播更多信息,与本站立场无关。仅供读者参考,并请自行核实相关内容。