<commit_before>## hash-set

hash-set is an implementation of the hash-set data structure. It has
constant time lookup, insertion and deletion.

Basic usage:

1. Assuming you use Quicklisp, clone this repo into your ```quicklisp/local-projects```.
2. ```(ql:register-local-projects)```
3. ```(ql:quickload 'hash-set)```
4. Enjoy.

### Function reference

Note: ```*!hash-set!*``` means the hash-set is destructively
modified. Functions that are destructive have an 'n' in front of their
name like CL's ```reverse``` and ```nreverse```. So, the destructive
version of ```hs-insert``` is ```hs-ninsert```.

##### make-hash-set : ```() -> hash-set```

Creates a new hash-set

```lisp
(let ((hash-set (make-hash-set)))
  ;; Operations on hash-set
  )
```

##### list-to-hs : ```list -> hash-set```

Creates a hash-set containing all the elements of a list.

```lisp
HASH-SET> (list-to-hs (alexandria:iota 10))
#<HASH-SET of count: 10 {1008832EF3}>
```

##### hs-to-list : ```hash-set -> list```

Creates a list containing all the elements of the hash-set

```lisp
HASH-SET> (hs-to-list (list-to-hs (alexandria:iota 10)))
(0 1 2 3 4 5 6 7 8 9)
```

##### hs-count : ```hash-set -> integer```

Return the number of elements in the hash-set.

```lisp
HASH-SET> (hs-count (list-to-hs '(4 5 6 7)))
4
```

##### hs-emptyp : ```hash-set -> bool```

Predicate that tests whether the hash-set is empty or not.

```lisp
HASH-SET> (hs-emptyp (make-hash-set))
T
```

##### hs-equal : ```hash-set hash-set -> bool```

Compares two hash-sets for equality.

```lisp
HASH-SET> (hs-equal (list-to-hs '(7 8 9))
                    (list-to-hs '(7 8 9)))
T
```

##### hs-copy : ```hash-set -> hash-set```

Returns a copy of the hash-set.

```lisp
HASH-SET> (let ((hash-set (list-to-hs '(1 2 3 4))))
            (hs-equal hash-set
                      (hs-copy hash-set)))
T
```

##### hs-memberp : ```hash-set elt -> bool```

Predicate that tests the existence of an element in the hash-set.

```lisp
HASH-SET> (let ((hash-set (list-to-hs '(1 2 3 4))))
            (hs-memberp hash-set 4))
(4)
T
HASH-SET> (let ((hash-set (list-to-hs '(1 2 3 4))))
            (hs-memberp hash-set 8))
NIL
NIL
```

##### hs-map : ```function hash-set -> hash-set```

Maps a function over a hash-set and returns a hash-set containing all the mapped values.

```lisp
HASH-SET> (hs-to-list (hs-map (lambda (x) (* x x))
                              (list-to-hs (alexandria:iota 10))))
(0 1 4 9 16 25 36 49 64 81)
```

##### hs-filter : ```function hash-set -> hash-set```

Filters out elements from a hash-set that test true with ```function```.

```lisp
HASH-SET> (hs-to-list (hs-filter #'oddp
                                 (list-to-hs (alexandria:iota 10))))
(1 3 5 7 9)
```

##### dohashset

Do something with each element of the hash-set.

#### Insertion/Deletion

##### hs-insert : ```hash-set elt -> hash-set```

Returns a new hash-set which contains the element ```elt``` in
addition to all the elements of the hash-set given as the argument.

```lisp
HASH-SET> (hs-to-list (hs-insert (list-to-hs '(4 5 6)) 123))
(4 5 6 123)
```

##### hs-ninsert : ```hash-set elt -> *!hash-set!*```

Inserts elt into the hash-set and returns the modified hash-set.

```lisp
HASH-SET> (let ((hash-set (list-to-hs '(1 2 3 4))))
            (hs-ninsert hash-set 1984)
            (hs-to-list hash-set))
(1 2 3 4 1984)
```

##### hs-remove : ```hash-set elt -> hash-set```

Returns a copy of the hash-set, but with the element ```elt``` removed from it.

```
HASH-SET> (hs-to-list (hs-remove (list-to-hs '(4 5 6 7)) 5))
(4 6 7)
```

##### hs-nremove : ```hash-set elt -> *!hash-set!*```

Removes the element ```elt``` from the hash-set.

##### hs-remove-if : ```predicate hash-set -> hash-set```

```lisp
HASH-SET> (hs-to-list (hs-remove-if #'evenp (list-to-hs (alexandria:iota 10))))<commit_msg>Add example for dohashset<commit_after>## hash-set

hash-set is an implementation of the hash-set data structure. It has
constant time lookup, insertion and deletion.

Basic usage:

1. Assuming you use Quicklisp, clone this repo into your ```quicklisp/local-projects```.
2. ```(ql:register-local-projects)```
3. ```(ql:quickload 'hash-set)```
4. Enjoy.

### Function reference

Note: ```*!hash-set!*``` means the hash-set is destructively
modified. Functions that are destructive have an 'n' in front of their
name like CL's ```reverse``` and ```nreverse```. So, the destructive
version of ```hs-insert``` is ```hs-ninsert```.

##### make-hash-set : ```() -> hash-set```

Creates a new hash-set

```lisp
(let ((hash-set (make-hash-set)))
  ;; Operations on hash-set
  )
```

##### list-to-hs : ```list -> hash-set```

Creates a hash-set containing all the elements of a list.

```lisp
HASH-SET> (list-to-hs (alexandria:iota 10))
#<HASH-SET of count: 10 {1008832EF3}>
```

##### hs-to-list : ```hash-set -> list```

Creates a list containing all the elements of the hash-set

```lisp
HASH-SET> (hs-to-list (list-to-hs (alexandria:iota 10)))
(0 1 2 3 4 5 6 7 8 9)
```

##### hs-count : ```hash-set -> integer```

Return the number of elements in the hash-set.

```lisp
HASH-SET> (hs-count (list-to-hs '(4 5 6 7)))
4
```

##### hs-emptyp : ```hash-set -> bool```

Predicate that tests whether the hash-set is empty or not.

```lisp
HASH-SET> (hs-emptyp (make-hash-set))
T
```

##### hs-equal : ```hash-set hash-set -> bool```

Compares two hash-sets for equality.

```lisp
HASH-SET> (hs-equal (list-to-hs '(7 8 9))
                    (list-to-hs '(7 8 9)))
T
```

##### hs-copy : ```hash-set -> hash-set```

Returns a copy of the hash-set.

```lisp
HASH-SET> (let ((hash-set (list-to-hs '(1 2 3 4))))
            (hs-equal hash-set
                      (hs-copy hash-set)))
T
```

##### hs-memberp : ```hash-set elt -> bool```

Predicate that tests the existence of an element in the hash-set.

```lisp
HASH-SET> (let ((hash-set (list-to-hs '(1 2 3 4))))
            (hs-memberp hash-set 4))
(4)
T
HASH-SET> (let ((hash-set (list-to-hs '(1 2 3 4))))
            (hs-memberp hash-set 8))
NIL
NIL
```

##### dohashset

Do something with each element of the hash-set.

```lisp
HASH-SET> (dohashset (elt (list-to-hs (alexandria:iota 10)))
            (princ elt))
0123456789
NIL
```

##### hs-map : ```function hash-set -> hash-set```

Maps a function over a hash-set and returns a hash-set containing all the mapped values.

```lisp
HASH-SET> (hs-to-list (hs-map (lambda (x) (* x x))
                              (list-to-hs (alexandria:iota 10))))
(0 1 4 9 16 25 36 49 64 81)
```

##### hs-filter : ```function hash-set -> hash-set```

Filters out elements from a hash-set that test true with ```function```.

```lisp
HASH-SET> (hs-to-list (hs-filter #'oddp
                                 (list-to-hs (alexandria:iota 10))))
(1 3 5 7 9)
```

#### Insertion/Deletion

##### hs-insert : ```hash-set elt -> hash-set```

Returns a new hash-set which contains the element ```elt``` in
addition to all the elements of the hash-set given as the argument.

```lisp
HASH-SET> (hs-to-list (hs-insert (list-to-hs '(4 5 6)) 123))
(4 5 6 123)
```

##### hs-ninsert : ```hash-set elt -> *!hash-set!*```

Inserts elt into the hash-set and returns the modified hash-set.

```lisp
HASH-SET> (let ((hash-set (list-to-hs '(1 2 3 4))))
            (hs-ninsert hash-set 1984)
            (hs-to-list hash-set))
(1 2 3 4 1984)
```

##### hs-remove : ```hash-set elt -> hash-set```

Returns a copy of the hash-set, but with the element ```elt``` removed from it.

```lisp
HASH-SET> (hs-to-list (hs-remove (list-to-hs '(4 5 6 7)) 5))
(4 6 7)
```

##### hs-nremove : ```hash-set elt -> *!hash-set!*```

Removes the element ```elt``` from the hash-set.

##### hs-remove-if : ```predicate hash-set -> hash-set```

```lisp
HASH-SET> (hs-to-list (hs-remove-if #'evenp (list-to-hs (alexandria:iota 10))))
{'fraction_non_alphanumeric': 0.20376055257099002, 'fraction_numerical': 0.031465848042977744, 'mean_word_length': 3.042916235780765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5148981', 'n_tokens_mistral': 3222, 'n_tokens_neox': 2881, 'n_words': 946}