commit d59d747678981fc3c44465541f66d4802b29fa69 Author: Stephen Seo Date: Sun Dec 6 17:55:30 2020 +0900 Init skeleton project diff --git a/c_impl/.gitignore b/c_impl/.gitignore new file mode 100644 index 0000000..2247c64 --- /dev/null +++ b/c_impl/.gitignore @@ -0,0 +1,5 @@ +listSlices_c +src/*.o + +.cache/ +compile_commands.json diff --git a/c_impl/Makefile b/c_impl/Makefile new file mode 100644 index 0000000..c114eb7 --- /dev/null +++ b/c_impl/Makefile @@ -0,0 +1,18 @@ +COMMON_FLAGS = -Wall -Wextra -Wpedantic + +ifdef DEBUG + CFLAGS = $(COMMON_FLAGS) -O0 -g +else + CFLAGS = $(COMMON_FLAGS) -O3 -DNDEBUG +endif + +all: listSlices_c + +listSlices_c: src/main.o + $(CC) $(CFLAGS) -o listSlices_c $^ + +.PHONY: + +clean: + rm -f src/main.o + rm -f listSlices_c diff --git a/c_impl/src/main.c b/c_impl/src/main.c new file mode 100644 index 0000000..11b7fad --- /dev/null +++ b/c_impl/src/main.c @@ -0,0 +1,3 @@ +int main(int argc, char **argv) { + return 0; +} diff --git a/link b/link new file mode 100644 index 0000000..fb320b7 --- /dev/null +++ b/link @@ -0,0 +1 @@ +https://programmingpraxis.com/2020/10/27/list-slices/ diff --git a/problem b/problem new file mode 100644 index 0000000..ccd5547 --- /dev/null +++ b/problem @@ -0,0 +1,12 @@ +During some recent personal programming, I needed a function to slice a list +into pieces: Given a list of sub-list lengths, and an input list to be sliced, +return a list of sub-lists of the requested lengths. For instance:, slicing the +list (1 2 2 3 3 3) into sub-lists of lengths (1 2 3) returns the list of +sub-lists ((1) (2 2) (3 3 3)). Extra list elements at the end of the input list +are ignored, missing list elements at the end of the input list are returned as +null lists. + +Your task is to write a program that slices lists into sub-lists according to a +specification of sub-list lengths. When you are finished, you are welcome to +read or run a suggested solution, or to post your own solution or discuss the +exercise in the comments below.