or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
CS1101S Studio S5 (T08C)
Data Abstractions
Question 1
Draw box-and-pointer for the values of the following expressions. Also give box and list notation.
Question 2
Examine the following (incorrect)
reverse
function:Draw the box-and-pointer diagram, box notation and list notation for the result returned by the following function call:
Question 3
Write expressions using
lst
,head
andtail
that will return 1 when thelst
is bound to the following values:Bonus Round
Question 1
The function
list_ref
can be applied to a listxs
and a numbern
, and returns then
-th element of the list, starting counting at 0. Solist_ref(list(1, 2, 3), 2)
evaluates to 3. The position of an element in the list is called its rank; we say that the number 3 has rank 2 in the list. Write a Source function calledevery_second
that takes a list as its only argument and returns a list containing all the elements of odd rank (i.e. every second element) from the input list.Question 2
Write a Source §2 function called
sums
that takes a list of numbers as its only argument and returns a list of numbers, containing two elements: the first is the sum of all even-ranked numbers in the input list (ranks 0, 2, 4 etc), whereras the second element is the sum of all odd-ranked elements in the input list (ranks 1, 3, 5 etc).