ANU COMP1100 Lab1简介
现在可以开始写lab1了朋友们:https://cs.anu.edu.au/courses/comp1100/labs/01/
没注册的同学火速去注册lab: https://cs.anu.edu.au/streams/
安装虚拟机 (可以去csit的同学请跳过!)
lab1不需要在自己电脑上安装haskell,必须远程anu电脑使用Linux。
想安装Haskell的同学看这里: https://cs.anu.edu.au/courses/comp1100/resources/10-install/
- 下载安装global protection
a) 下载链接:https://student-access.anu.edu.au/global-protect/login.esp
b) 安装成功忽略此条!如果安装的时候提示权限不够,windows试试:打开powershell(admin)然后输入 msiexec /package 文件路径\GlobalProtect64.msi
c) 使用教程:安装好以后打开软件,portal填:student-access.anu.edu.au,然后用uid密码登录连接
不明白的同学有视频给大家:
Global Protect 安装连接教程 - ANU
- 下载安装VMWare
a) 下载链接:https://linuxvdi.anu.edu.au/
第一个是安装,第二个是网页直接访问
可能要科学上网,可以连上global protect下载。也可以网页上直接访问,但会慢一些。
b) 使用教程:https://cs.anu.edu.au/courses/comp1100/resources/02-working-remotely/
lab1正题:
网站介绍
COMP1100课程网站: https://cs.anu.edu.au/courses/comp1100
- 包含所有lecture/lab/assessment信息
Piaza论坛: https://piazza.com/anu.edu.au
- 按照规范提问,tutor/student看到会尽快回答
GitLab: https://gitlab.cecs.anu.edu.au/users/sign_in
- 下载和上传作业的地方!
按照instruction创建comp1100及子目录
截图自: https://cs.anu.edu.au/courses/comp1100/labs/01/
按照instruction打开workspace
截图自: https://cs.anu.edu.au/courses/comp1100/labs/01/
截图自: https://cs.anu.edu.au/courses/comp1100/labs/01/
按照instruction配置VSCodium
截图自: https://cs.anu.edu.au/courses/comp1100/labs/01/
截图自: https://cs.anu.edu.au/courses/comp1100/labs/01/
截图自: https://cs.anu.edu.au/courses/comp1100/labs/01/
打开terminal 输入ghci, 尝试:
-- 复制自:https://cs.anu.edu.au/courses/comp1100/labs/01/
6 < 4
compare 4 5
compare (Just 5) Nothing
Nothing
True && False
True || False -- The ‘|’ character is called a “pipe” (found near the <Enter> key).
(1 + 1 == 2) || (1 + 1 == 3)
2 ^ 5
lcm 4 14
sqrt 2.0
sqrt 4*100 -- Think carefully about the output you get from this one.
sin (pi/2.0)
[1 .. 10]
sum [1 .. 100]
product [1, 3 .. 10]
“Out” ++ “shined”
length “Room a thousand years wide”
words “Fell on black days”
输入 :q
退出ghci
打开VSCodium
视频版说明
ANU COMP1100 LAB1 - Haskell示范
文字版说明
新建文件另存为Area.hs, 输入:
module Area where
-- add 1 to an integer <- this a comment that tells the user what the function does.
addOne :: Integer -> Integer
addOne int = int + 1
按Ctrl+Shift+P,输入terminal打开terminal,输入:ghci -Wall Area.hs
显示:
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Area ( Area.hs, interpreted )
Ok, modules loaded: Area.
*Area>
说明文件读取成功,尝试:
*Area> addOne 1
2
*Area> addOne 5
6
*Area> addOne 10
11
在Area.hs文件里面添加并修复:
-- calculate area of a square with only integer lengths
areaSquare :: Integer -> Integer
areaSquare len = undefined
terminal输入::r
重新加载Area.hs文件
尝试:
*Area> areaSquare 3
9
*Area> areaSquare 10
100
剩下的Exercise就交给大家自己解决了噢!关于function/type signiture及后续更多内容我们就以后再见咯!
其他
- 遇到这个问题的同学在指令后面加 --force,可以强制安装
- 遇到这个问题的同学先:q退出ghci,然后cd 到hs文件所在的地址
- VMWare/Haskell必须装吗?lab1必须要用VMWare! 如果虚拟机用的不卡顿的话, Haskell不是必须要在自己电脑上安装!
- 如果出现这个问题试试看运行powershell(admin)