Skip to content

Commit e359f3e

Browse files
authored
Add take and drop functions for list library (#386)
* Add take and drop * Small change to scss file
1 parent ca0cc5b commit e359f3e

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

public/externalLibs/list.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,24 @@ function set_tail(xs,x) {
373373
}
374374
}
375375

376+
// take(xs, n) puts the first n elements of xs into a list.
377+
function take(xs, n) {
378+
if (n < 0) {
379+
throw new Error("take(xs, n) expects a positive integer as " +
380+
"argument n, but encountered " + n);
381+
}
382+
return (n === 0) ? [] : pair(head(xs), take(tail(xs), n - 1));
383+
}
384+
385+
// drop(xs, n) removes the first n elements from xs and returns the rest (as a list)
386+
function drop(xs, n) {
387+
if (n < 0) {
388+
throw new Error("drop(xs, n) expects a positive integer as " +
389+
"argument n, but encountered " + n);
390+
}
391+
return (n === 0) ? xs : drop(tail(xs), n - 1);
392+
}
393+
376394
//function display(str) {
377395
// var to_show = str;
378396
// if (is_array(str) && str.length > 2) {

src/styles/_academy.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@
226226
text-align: left;
227227
}
228228

229-
md th,
230-
td {
229+
.md th,
230+
.md td {
231231
text-align: left;
232232
padding: 8px;
233233
}
234234

235-
md tr:nth-child(even) {
235+
.md tr:nth-child(even) {
236236
background-color: #f2f2f2;
237237
}

0 commit comments

Comments
 (0)