Init skeleton project
This commit is contained in:
commit
d59d747678
5 changed files with 39 additions and 0 deletions
5
c_impl/.gitignore
vendored
Normal file
5
c_impl/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
listSlices_c
|
||||
src/*.o
|
||||
|
||||
.cache/
|
||||
compile_commands.json
|
18
c_impl/Makefile
Normal file
18
c_impl/Makefile
Normal file
|
@ -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
|
3
c_impl/src/main.c
Normal file
3
c_impl/src/main.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
1
link
Normal file
1
link
Normal file
|
@ -0,0 +1 @@
|
|||
https://programmingpraxis.com/2020/10/27/list-slices/
|
12
problem
Normal file
12
problem
Normal file
|
@ -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.
|
Loading…
Reference in a new issue