commit c460a26850eca5ded047d0eb0d183b861087aa53 parent 2e239a4ed2265f7c7dc2aabedfdb7d7b011704cb Author: standenboy <standenboy@seacrossedlovers.xyz> Date: Tue, 30 Apr 2024 14:22:45 +0100 write up update Diffstat:
55 files changed, 364 insertions(+), 329 deletions(-)
diff --git a/comp/cw/code/ads/ll/ll.c b/comp/cw/code/ads/ll/ll.c @@ -1,50 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(){ - ll_t *output = malloc(sizeof(ll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - return output; -} - -void llsetdata(ll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void llsetnext(ll_t *node, ll_t *next){ - if (node->next == NULL) - node->next = next; - else - llsetnext(node->next, next); -} - -void *llgetat(ll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return llgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void llfreeall(ll_t *head){ - if (head->next != NULL) - llfreeall(head->next); - free(head->data); - free(head); -} - diff --git a/comp/cw/code/ads/ll/ll.h b/comp/cw/code/ads/ll/ll.h @@ -1,15 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(); -void llsetdata(ll_t *node, void *data); -void llsetnext(ll_t *node, ll_t *next); -void *llgetat(ll_t *head, int index); -void llfreeall(ll_t *head); diff --git a/comp/cw/code/ads/ll/lltest b/comp/cw/code/ads/ll/lltest Binary files differ. diff --git a/comp/cw/code/ads/ll/lltest.c b/comp/cw/code/ads/ll/lltest.c @@ -1,18 +0,0 @@ -#include <stdio.h> - -#include "ll.h" - -int main(){ - ll_t *head = llalloc(); - llsetdata(head, "hello"); - - for (int i = 0; i < 3; i++){ - ll_t *node = llalloc(); - llsetdata(node, "hi"); - llsetnext(head, node); - } - for (int i = 0; i < 4; i++) - printf("%s\n", (char *)llgetat(head, i)); - - llfreeall(head); -} diff --git a/comp/cw/code/parser/parser.o b/comp/cw/code/parser/parser.o Binary files differ. diff --git a/comp/cw/code/parser/preprocessor.o b/comp/cw/code/parser/preprocessor.o Binary files differ. diff --git a/comp/cw/code/parser/readfile.o b/comp/cw/code/parser/readfile.o Binary files differ. diff --git a/comp/cw/code/tokenizer/ads/dict/Makefile b/comp/cw/code/tokenizer/ads/dict/Makefile @@ -1,4 +0,0 @@ -all: dict.c - cc dict.c -c -o dict.o -test: all - cc dict.o dicttest.c -o dicttest diff --git a/comp/cw/code/tokenizer/ads/dict/dict.c b/comp/cw/code/tokenizer/ads/dict/dict.c @@ -1,29 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct dict_t { - int id; - void *data; -}dict_t; - -dict_t *dictalloc(){ - dict_t *output = malloc(sizeof(dict_t)); - return output; -} - -int dictset(dict_t *dict, int id, void *data){ - dict->id = id; - - dict->data = malloc(sizeof(data)); - if (dict->data == NULL) - return 1; - memcpy(dict->data, data, sizeof(data)); - - return 0; -} - -void dictfree(dict_t *dict){ - free(dict->data); - free(dict); -} - diff --git a/comp/cw/code/tokenizer/ads/dict/dict.h b/comp/cw/code/tokenizer/ads/dict/dict.h @@ -1,9 +0,0 @@ -typedef struct dict_t { - int id; - void *data; -}dict_t; - -dict_t *dictalloc(); -int dictset(dict_t *dict, int id, void *data); -void dictfree(dict_t *dict); - diff --git a/comp/cw/code/tokenizer/ads/dict/dict.o b/comp/cw/code/tokenizer/ads/dict/dict.o Binary files differ. diff --git a/comp/cw/code/tokenizer/ads/dict/dicttest b/comp/cw/code/tokenizer/ads/dict/dicttest Binary files differ. diff --git a/comp/cw/code/tokenizer/ads/dict/dicttest.c b/comp/cw/code/tokenizer/ads/dict/dicttest.c @@ -1,10 +0,0 @@ -#include <stdio.h> - -#include "dict.h" - -int main(){ - dict_t *dict = dictalloc(); - dictset(dict, 1, "hello"); - printf("%d:%s\n", dict->id, (char *)dict->data); - dictfree(dict); -} diff --git a/comp/cw/code/tokenizer/ads/dll/Makefile b/comp/cw/code/tokenizer/ads/dll/Makefile @@ -1,5 +0,0 @@ -all: dll.c - cc dll.c -c -o dll.o - -test: all - cc dll.o dlltest.c -o dlltest diff --git a/comp/cw/code/tokenizer/ads/dll/dll.c b/comp/cw/code/tokenizer/ads/dll/dll.c @@ -1,62 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct dll_t dll_t; - -typedef struct dll_t { - void *data; - dll_t *next; - dll_t *prev; -} dll_t; - -dll_t *dllalloc(){ - dll_t *output = malloc(sizeof(dll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - output->prev = NULL; - return output; -} - -void dllsetdata(dll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void dllsetnext(dll_t *node, dll_t *next){ - if (node->next == NULL) { - node->next = next; - node->next->prev = node; - } - else - dllsetnext(node->next, next); -} -void dllsetprev(dll_t *node, dll_t *prev){ - if (node->prev == NULL) { - node->prev = prev; - node->prev->next = node; - } - else - dllsetprev(node->prev, prev); -} - -void *dllgetat(dll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return dllgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void dllfreeall(dll_t *head){ - if (head->next != NULL) - dllfreeall(head->next); - free(head->data); - free(head); -} - diff --git a/comp/cw/code/tokenizer/ads/dll/dll.h b/comp/cw/code/tokenizer/ads/dll/dll.h @@ -1,19 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct dll_t dll_t; - -typedef struct dll_t { - void *data; - dll_t *next; - dll_t *prev; -} dll_t; - -dll_t *dllalloc(); -void dllsetdata(dll_t *node, void *data); -void dllsetnext(dll_t *node, dll_t *next); -void dllsetprev(dll_t *node, dll_t *prev); -void *dllgetat(dll_t *head, int index); -void dllfreeall(dll_t *head); - diff --git a/comp/cw/code/tokenizer/ads/dll/dll.o b/comp/cw/code/tokenizer/ads/dll/dll.o Binary files differ. diff --git a/comp/cw/code/tokenizer/ads/dll/dlltest b/comp/cw/code/tokenizer/ads/dll/dlltest Binary files differ. diff --git a/comp/cw/code/tokenizer/ads/dll/dlltest.c b/comp/cw/code/tokenizer/ads/dll/dlltest.c @@ -1,20 +0,0 @@ -#include <stdio.h> - -#include "dll.h" - -int main(){ - dll_t *head = dllalloc(); - dllsetdata(head, "hello"); - - for (int i = 0; i < 3; i++){ - dll_t *node = dllalloc(); - dllsetdata(node, "hi"); - dllsetnext(head, node); - } - - for (int i = 0; i < 4; i++) - printf("%s\n", (char *)dllgetat(head, i)); - printf("%s\n", (char *)head->prev->next->data); - - dllfreeall(head); -} diff --git a/comp/cw/code/tokenizer/ads/ll/Makefile b/comp/cw/code/tokenizer/ads/ll/Makefile @@ -1,5 +0,0 @@ -all: ll.c - cc ll.c -c -o ll.o - -test: all - cc ll.o lltest.c -o lltest diff --git a/comp/cw/code/tokenizer/ads/ll/ll.c b/comp/cw/code/tokenizer/ads/ll/ll.c @@ -1,50 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(){ - ll_t *output = malloc(sizeof(ll_t)); - if (output == NULL) - return NULL; - output->next = NULL; - return output; -} - -void llsetdata(ll_t *node, void *data){ - node->data = malloc(sizeof(data)); - memcpy(node->data, data, sizeof(data)); -} - -void llsetnext(ll_t *node, ll_t *next){ - if (node->next == NULL) - node->next = next; - else - llsetnext(node->next, next); -} - -void *llgetat(ll_t *head, int index){ - if (index == 0) - return head->data; - else { - if (head->next != NULL) { - return llgetat(head->next, index - 1); - }else { - return NULL; - } - } -} - -void llfreeall(ll_t *head){ - if (head->next != NULL) - llfreeall(head->next); - free(head->data); - free(head); -} - diff --git a/comp/cw/code/tokenizer/ads/ll/ll.h b/comp/cw/code/tokenizer/ads/ll/ll.h @@ -1,15 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -typedef struct ll_t ll_t; - -typedef struct ll_t { - void *data; - ll_t *next; -} ll_t; - -ll_t *llalloc(); -void llsetdata(ll_t *node, void *data); -void llsetnext(ll_t *node, ll_t *next); -void *llgetat(ll_t *head, int index); -void llfreeall(ll_t *head); diff --git a/comp/cw/code/tokenizer/ads/ll/ll.o b/comp/cw/code/tokenizer/ads/ll/ll.o Binary files differ. diff --git a/comp/cw/code/tokenizer/ads/ll/lltest b/comp/cw/code/tokenizer/ads/ll/lltest Binary files differ. diff --git a/comp/cw/code/tokenizer/ads/ll/lltest.c b/comp/cw/code/tokenizer/ads/ll/lltest.c @@ -1,18 +0,0 @@ -#include <stdio.h> - -#include "ll.h" - -int main(){ - ll_t *head = llalloc(); - llsetdata(head, "hello"); - - for (int i = 0; i < 3; i++){ - ll_t *node = llalloc(); - llsetdata(node, "hi"); - llsetnext(head, node); - } - for (int i = 0; i < 4; i++) - printf("%s\n", (char *)llgetat(head, i)); - - llfreeall(head); -} diff --git a/comp/lucas-standen-NEA/code/Makefile b/comp/lucas-standen-NEA/code/Makefile @@ -0,0 +1,6 @@ +all: + cd ads; make + cd parser; make + +tests: all + cd ads; make tests diff --git a/comp/lucas-standen-NEA/code/ads/Makefile b/comp/lucas-standen-NEA/code/ads/Makefile @@ -0,0 +1,6 @@ +all: + cd dict; make + cd ll; make +tests: all + cd dict; make test + cd ll; make test diff --git a/comp/cw/code/ads/dict/Makefile b/comp/lucas-standen-NEA/code/ads/dict/Makefile diff --git a/comp/cw/code/ads/dict/dict.c b/comp/lucas-standen-NEA/code/ads/dict/dict.c diff --git a/comp/cw/code/ads/dict/dict.h b/comp/lucas-standen-NEA/code/ads/dict/dict.h diff --git a/comp/cw/code/ads/dict/dicttest b/comp/lucas-standen-NEA/code/ads/dict/dicttest Binary files differ. diff --git a/comp/cw/code/ads/dict/dicttest.c b/comp/lucas-standen-NEA/code/ads/dict/dicttest.c diff --git a/comp/cw/code/ads/ll/Makefile b/comp/lucas-standen-NEA/code/ads/ll/Makefile diff --git a/comp/lucas-standen-NEA/code/ads/ll/ll.c b/comp/lucas-standen-NEA/code/ads/ll/ll.c @@ -0,0 +1,57 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +typedef struct ll_t ll_t; + +typedef struct ll_t { + void *data; + ll_t *next; +} ll_t; + +ll_t *llalloc(){ + ll_t *output = malloc(sizeof(ll_t)); + if (output == NULL) + return NULL; + output->next = NULL; + return output; +} + +void llsetdata(ll_t *node, void *data){ + node->data = malloc(sizeof(data)); + memcpy(node->data, data, sizeof(data)); +} + +void llsetnext(ll_t *node, ll_t *next){ + if (node->next == NULL) + node->next = next; + else + llsetnext(node->next, next); +} + +void *llgetat(ll_t *head, int index){ + if (index == 0) + return head->data; + else { + if (head->next != NULL) { + return llgetat(head->next, index - 1); + }else { + return NULL; + } + } +} + +ll_t *llgetendnode(ll_t *head){ + if (head->next == NULL) + return head; + else + return llgetendnode(head->next); +} + +void llfreeall(ll_t *head){ + if (head->next != NULL) + llfreeall(head->next); + free(head->data); + free(head); +} + diff --git a/comp/lucas-standen-NEA/code/ads/ll/ll.h b/comp/lucas-standen-NEA/code/ads/ll/ll.h @@ -0,0 +1,16 @@ +#include <stdlib.h> +#include <string.h> + +typedef struct ll_t ll_t; + +typedef struct ll_t { + void *data; + ll_t *next; +} ll_t; + +ll_t *llalloc(); +void llsetdata(ll_t *node, void *data); +void llsetnext(ll_t *node, ll_t *next); +void *llgetat(ll_t *head, int index); +ll_t *llgetendnode(ll_t *head); +void llfreeall(ll_t *head); diff --git a/comp/lucas-standen-NEA/code/ads/ll/lltest b/comp/lucas-standen-NEA/code/ads/ll/lltest Binary files differ. diff --git a/comp/lucas-standen-NEA/code/ads/ll/lltest.c b/comp/lucas-standen-NEA/code/ads/ll/lltest.c @@ -0,0 +1,19 @@ +#include <stdio.h> + +#include "ll.h" + +int main(){ + ll_t *head = llalloc(); + llsetdata(head, "hello"); + + for (int i = 0; i < 3; i++){ + ll_t *node = llalloc(); + llsetdata(node, "hi"); + llsetnext(head, node); + } + for (int i = 0; i < 4; i++) + printf("%s\n", (char *)llgetat(head, i)); + printf("%s\n", llgetendnode(head)->data); + + llfreeall(head); +} diff --git a/comp/cw/code/parser/Makefile b/comp/lucas-standen-NEA/code/parser/Makefile diff --git a/comp/cw/code/parser/parser b/comp/lucas-standen-NEA/code/parser/parser Binary files differ. diff --git a/comp/cw/code/parser/parser.c b/comp/lucas-standen-NEA/code/parser/parser.c diff --git a/comp/cw/code/parser/preprocessor.c b/comp/lucas-standen-NEA/code/parser/preprocessor.c diff --git a/comp/cw/code/parser/preprocessor.h b/comp/lucas-standen-NEA/code/parser/preprocessor.h diff --git a/comp/cw/code/parser/readfile.c b/comp/lucas-standen-NEA/code/parser/readfile.c diff --git a/comp/cw/code/parser/readfile.h b/comp/lucas-standen-NEA/code/parser/readfile.h diff --git a/comp/cw/code/parser/sample.zpy b/comp/lucas-standen-NEA/code/parser/sample.zpy diff --git a/comp/cw/overview b/comp/lucas-standen-NEA/overview diff --git a/comp/lucas-standen-NEA/writeup/coverpage.html b/comp/lucas-standen-NEA/writeup/coverpage.html @@ -0,0 +1,131 @@ +<!-- Creator : groff version 1.23.0 --> +<!-- CreationDate: Tue Apr 30 14:21:39 2024 --> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" +"http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> +<meta name="generator" content="groff -Thtml, see www.gnu.org"> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<meta name="Content-Style" content="text/css"> +<style type="text/css"> + p { margin-top: 0; margin-bottom: 0; vertical-align: top } + pre { margin-top: 0; margin-bottom: 0; vertical-align: top } + table { margin-top: 0; margin-bottom: 0; vertical-align: top } + h1 { text-align: center } +</style> +<title>NEA coverpage</title> + +</head> +<body> + +<h1 align="center">NEA coverpage</h1> + +<a href="#1. Analysis">1. Analysis</a><br> +<a href="#1.1. Overview">1.1. Overview</a><br> +<a href="#1.2. Examples of similar projects">1.2. Examples of similar projects</a><br> +<a href="#1.2.1. Python">1.2.1. Python</a><br> +<a href="#1.2.2. Lisp">1.2.2. Lisp</a><br> +<a href="#1.2.3. Perl">1.2.3. Perl</a><br> +<a href="#2. Design">2. Design</a><br> +<a href="#3. Technical Solution">3. Technical Solution</a><br> +<a href="#4. Testing">4. Testing</a><br> +<a href="#5. Evaluation">5. Evaluation</a><br> + +<hr> + + +<p align="center"><i>Lucas standen</i> <br> +7949</p> + + +<p align="center" style="margin-top: 1em"><i>ABSTRACT</i></p> + +<h2>1. Analysis +<a name="1. Analysis"></a> +</h2> + + +<h3>1.1. Overview +<a name="1.1. Overview"></a> +</h3> + + +<p style="margin-top: 1em"><i><b>Zippy LANG</b></i></p> + +<p style="margin-top: 1em">A next generation language, for +general use. Designed for keeping code simple, neet and +readable. <br> +Zippy will be a modern functional language. It will be +interpreted like python/perl and lisp. Its syntax should be +similar to lisp.</p> + +<p style="margin-top: 1em">Some interesting features that +Zippy will have is treating everthing in functions, scopes +that allow for manual but safe memory management, and +interoperablity with C <br> +libarys</p> + +<h3>1.2. Examples of similar projects +<a name="1.2. Examples of similar projects"></a> +</h3> + + +<h4>1.2.1. Python +<a name="1.2.1. Python"></a> +</h4> + + +<p style="margin-top: 1em">Python is a high level OOP +language that was designed in 1991. It was made to make +programming easy whie still being able to use some of +C’s functions. <br> +Although it has become standard for many usecases, it is +slow and inefficent, and very bloated.</p> + +<h4>1.2.2. Lisp +<a name="1.2.2. Lisp"></a> +</h4> + + +<p style="margin-top: 1em">Lisp is the second ever +programming language, developed at MiT, it is the first +functional language, creating many common features like +higher order functions, <br> +recursion, and garbage collection. It is generally not used +anymore as it feels old compared to other functional +languages, like ocaml or haskell.</p> + +<h4>1.2.3. Perl +<a name="1.2.3. Perl"></a> +</h4> + + +<p style="margin-top: 1em">Perl is scripting lang designed +for use in linux, when bash is too slow, or not suited for +the job. <br> +Perl is often described as the glue of the universe (see +xkcd https://3d.xkcd.com/224/). Its syntax is quite strange +however and it is slow. Making it poorly suited for general +use.</p> + +<h2>2. Design +<a name="2. Design"></a> +</h2> + + +<h2>3. Technical Solution +<a name="3. Technical Solution"></a> +</h2> + + +<h2>4. Testing +<a name="4. Testing"></a> +</h2> + + +<h2>5. Evaluation +<a name="5. Evaluation"></a> +</h2> +<hr> +</body> +</html> diff --git a/comp/lucas-standen-NEA/writeup/coverpage.ms b/comp/lucas-standen-NEA/writeup/coverpage.ms @@ -0,0 +1,46 @@ +.TL +NEA coverpage +.AU +Lucas standen +.AI +7949 +.AB +.NH 1 +Analysis +.NH 2 +Overview +.PP +.B Zippy +.B LANG +.PP +A next generation language, for general use. Designed for keeping code simple, neet and readable. + Zippy will be a modern functional language. It will be interpreted like python/perl and lisp. Its syntax should be similar to lisp. +.PP +Some interesting features that Zippy will have is treating everthing in functions, scopes that allow for manual but safe memory management, and interoperablity with C + libarys +.NH 2 +Examples of similar projects +.NH 3 +Python +.PP +Python is a high level OOP language that was designed in 1991. It was made to make programming easy whie still being able to use some of C's functions. + Although it has become standard for many usecases, it is slow and inefficent, and very bloated. +.NH 3 +Lisp +.PP +Lisp is the second ever programming language, developed at MiT, it is the first functional language, creating many common features like higher order functions, + recursion, and garbage collection. It is generally not used anymore as it feels old compared to other functional languages, like ocaml or haskell. +.NH 3 +Perl +.PP +Perl is scripting lang designed for use in linux, when bash is too slow, or not suited for the job. + Perl is often described as the glue of the universe (see xkcd https://3d.xkcd.com/224/). Its syntax is quite strange however and it is slow. Making it poorly suited for general use. +.NH 1 +Design +.NH 1 +Technical Solution +.NH 1 +Testing +.NH 1 +Evaluation +.AE diff --git a/comp/lucas-standen-NEA/writeup/coverpage.pdf b/comp/lucas-standen-NEA/writeup/coverpage.pdf Binary files differ. diff --git a/comp/lucas-standen-NEA/writeup/make.sh b/comp/lucas-standen-NEA/writeup/make.sh @@ -0,0 +1,2 @@ +#!/bin/bash +for i in $(ls | grep .ms); do groff -ms $i -T html > $(echo $i | cut -f1 -d".").html; done diff --git a/comp/work/31/__pycache__/bubble.cpython-312.pyc b/comp/work/31/__pycache__/bubble.cpython-312.pyc Binary files differ. diff --git a/comp/work/31/__pycache__/merge.cpython-312.pyc b/comp/work/31/__pycache__/merge.cpython-312.pyc Binary files differ. diff --git a/comp/work/31/bubble.py b/comp/work/31/bubble.py @@ -0,0 +1,22 @@ +import sys + + +def sort(list): + length = len(list) + for i in range(length - 1): + for j in range(length - i - 1): + if list[j] > list[j+1]: + tmp = list[j] + list[j] = list[j+1] + list[j+1] = tmp + return list + + +if __name__ == "__main__": + count = int(sys.argv[1]) + + num = [] + for i in range(count): + num.append(int(input(f"number {i}: "))) + + print(sort(num)) diff --git a/comp/work/31/menu.py b/comp/work/31/menu.py @@ -0,0 +1,20 @@ +import merge +import bubble + + +while True: + list = [] + inp = "" + print("enter nums, then enter END") + while inp != "END": + inp = input("number: ") + if inp != "END": + list.append(inp) + + sort = int(input("1) bubble, 2) merge: ")) + + if sort == 1: + print(*merge.sort(list), sep=", ") + + else: + print(*bubble.sort(list), sep=", ") diff --git a/comp/work/31/merge.py b/comp/work/31/merge.py @@ -0,0 +1,39 @@ +def sort(list): + length = len(list) + l1 = [] + l2 = [] + for i in range(length): + if i >= (length / 2): + l2.append(list[i]) + else: + l1.append(list[i]) + if length > 2: + l1 = sort(l1) + l2 = sort(l2) + return merge(l1, l2) + + +def merge(l1, l2): + i = 0 + j = 0 + output = [] + while i < len(l1) and j < len(l2): + if l1[i] < l2[j]: + output.append(l1[i]) + i += 1 + else: + output.append(l2[j]) + j += 1 + + while i < len(l1): + output.append(l1[i]) + i += 1 + while j < len(l2): + output.append(l2[j]) + j += 1 + return output + + +if __name__ == "__main__": + # call split on the list, will return a sorted one + print(sort([1, 4, 2, 4, 2, 5, 6, 2, 7]))