Skip to content

Commit f571a27

Browse files
authored
Merge pull request #4 from cgay/shared-library
Make shared library and use it for day-9
2 parents b9ee9ea + c99f30a commit f571a27

6 files changed

Lines changed: 34 additions & 8 deletions

File tree

day-9/day-9.dylan

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ Synopsis:
33
Author:
44
Copyright:
55

6-
define function get-int-vector-from-string(str :: <string>) => (ns :: <sequence>)
7-
let vec = make(<stretchy-vector>);
8-
for (i in str)
9-
add!(vec, string-to-integer(format-to-string("%c", i)));
10-
end;
11-
vec;
12-
end;
13-
146
define function get-cave-map () => (map :: <sequence>)
157
let cave-map = make(<stretchy-vector>);
168
with-open-file(file-stream = "list.txt")

day-9/library.dylan

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ define library day-9
66
use generic-arithmetic;
77
use system;
88
use strings;
9+
use shared;
910
end library day-9;
1011

1112
define module day-9
@@ -16,4 +17,5 @@ define module day-9
1617
use format-out;
1718
use format;
1819
use streams;
20+
use shared;
1921
end module day-9;

registry/generic/shared

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
abstract://dylan/shared/shared.lid

shared/library.dylan

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Module: dylan-user
2+
3+
define library shared
4+
use common-dylan;
5+
use io;
6+
7+
export shared;
8+
end library shared;
9+
10+
define module shared
11+
use common-dylan;
12+
use format-out;
13+
14+
export
15+
get-int-vector-from-string;
16+
end module shared;

shared/shared.dylan

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Module: shared
2+
Synopsis: Code shared between daily AOC libraries
3+
4+
// Convert a string containing only digit chars into a vector of integers, one for each
5+
// digit.
6+
define function get-int-vector-from-string (str :: <string>) => (ns :: <sequence>)
7+
map-as(<vector>,
8+
method (char)
9+
as(<integer>, char) - as(<integer>, '0')
10+
end,
11+
str)
12+
end function;

shared/shared.lid

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Library: shared
2+
Files: library
3+
shared

0 commit comments

Comments
 (0)