Skip to content

Commit

Permalink
Test, fix and document std/misc/prime (#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
fare authored Nov 23, 2023
1 parent 3c9bd08 commit 34a9b27
Show file tree
Hide file tree
Showing 11 changed files with 698 additions and 207 deletions.
60 changes: 31 additions & 29 deletions doc/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,26 @@ module.exports = {
path: "/reference/std/db/",
children: [
"db/",
"db/conpool",
"db/dbi",
"db/sqlite",
"db/postgresql",
"db/conpool",
"db/sqlite",
]
},

{ title: "Text Encoding and Decoding Libraries",
path: "/reference/std/text/",
children: [
"text/",
"text/json",
"text/base58",
"text/base64",
"text/char-set",
"text/csv",
"text/utf8",
"text/hex",
"text/json",
"text/utf16",
"text/utf32",
"text/base64",
"text/base58",
"text/hex",
"text/utf8",
"text/zlib"
]
},
Expand All @@ -153,41 +153,43 @@ module.exports = {
path: '/reference/std/misc/',
children: [
'misc/',
'misc/decimal',
'misc/list',
'misc/list-builder',
'misc/alist',
'misc/walist',
'misc/plist',
'misc/hash',
'misc/sync',
'misc/rbtree',
'misc/lru',
'misc/atom',
'misc/barrier',
'misc/bytes',
'misc/channel',
'misc/completion',
'misc/barrier',
'misc/rwlock',
'misc/threads',
'misc/queue',
'misc/decimal',
'misc/evector',
'misc/deque',
'misc/pqueue',
'misc/repr',
'misc/func',
'misc/hash',
'misc/list',
'misc/list-builder',
'misc/lru',
'misc/number',
'misc/path',
'misc/plist',
'misc/ports',
'misc/pqueue',
'misc/prime',
'misc/process',
'misc/bytes',
'misc/timeout',
'misc/queue',
'misc/rbtree',
'misc/repr',
'misc/rtd',
'misc/rwlock',
'misc/shared',
'misc/shuffle',
'misc/string',
'misc/path',
'misc/text',
'misc/sync',
'misc/template',
'misc/func',
'misc/number',
'misc/shuffle',
'misc/text',
'misc/threads',
'misc/timeout',
'misc/uuid',
'misc/vector',
'misc/walist',
]
}
]
Expand Down
81 changes: 81 additions & 0 deletions doc/reference/std/misc/evector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Extensible Vectors

The `:std/misc/evector` library implements extensible vectors,
that grow as you add elements to them, in the style of Common Lisp extensible vectors.

In this implementation, the underlying vectors double their size
each time they need to grow, guaranteeing constant factor size and time overhead
over having known the correct size initially.
The current implementation does not support shrinking an extensible vector,
but you can extract the non-extensible vector and forget the extensible one when you’re done.

`ebytes` and `ebits` are variants of `evector` specialized for holding
respectively 8-bit bytes and 1-bit bits.

::: tip To use the bindings from this module:
```scheme
(import :std/misc/evector)
```
:::

## evector
### make-evector
```scheme
(make-evector vector fill-pointer) => evector
```

Create an `evector` from initial values for the supporting `vector` and the `fill-pointer`.

Beware that the `vector` and the `evector` will share side-effects until the `evector` grows;
expected use is that ownership of the `vector` is transfered to the new `evector`.

::: tip Examples:
```scheme
> (make-evector #(1 2 3 #f) 3)
```
:::

### evector?
```scheme
(evector? x) => bool
```
Recognize an `evector`.

### check-argument-evector
### vector->evector &vector->evector
### evector->vector &evector->vector
### list->evector &list->evector
### evector->list &evector->list
### evector-ref &evector-ref
### evector-set! &evector-set! evector-ref-set! &evector-ref-set!
### extend-evector! &extend-evector!
### evector-push! &evector-push!
### evector-fill-pointer-set! &evector-fill-pointer-set!
### memoize-recursive-sequence

## ebytes
### make-ebytes
### ebytes?
### check-argument-ebytes
### bytes->ebytes &bytes->ebytes
### string->ebytes &string->ebytes
### ebytes-ref &ebytes-ref
### ebytes-set! &ebytes-set! ebytes-ref-set! &ebytes-ref-set!
### extend-ebytes! &extend-ebytes!
### ebytes-push! &ebytes-push!
### ebytes->bytes &ebytes->bytes
### ebytes-fill-pointer
### ebytes-fill-pointer-set!

## ebits
### make-ebits
### ebits?
### check-argument-ebits
### bits->ebits &bits->ebits
### ebits-set? &ebits-set?
### ebits-ref &ebits-ref
### ebits-set! &ebits-set! ebits-ref-set! &ebits-ref-set!
### extend-ebits! &extend-ebits!
### ebits-push! &ebits-push!
### ebits-fill-pointer-set!
### ebits-fill-pointer
17 changes: 17 additions & 0 deletions doc/reference/std/misc/number.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,23 @@ If `pred?` isn't actually increasing, return some integer in the interval.

## Modular Arithmetics

### divides?
```scheme
(divides f n) -> bool
```

Given two integers `f` and `n`, return true if `f` is a dividing factor of `n`,
i.e. there exists a `g` such that `n=f*g`.

::: tip Examples:
```scheme
> (divides? 2 256)
#t
> (divides? 2 255)
#f
```
:::

### bezout
```scheme
(bezout a b) -> (values integer integer integer)
Expand Down
Loading

0 comments on commit 34a9b27

Please sign in to comment.