Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/griba2001/urweb-dequeue
Double ended queue over split list implementation
https://github.com/griba2001/urweb-dequeue
Last synced: 3 months ago
JSON representation
Double ended queue over split list implementation
- Host: GitHub
- URL: https://github.com/griba2001/urweb-dequeue
- Owner: griba2001
- Created: 2015-08-07T14:48:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-10T11:23:17.000Z (over 9 years ago)
- Last Synced: 2024-08-03T03:02:15.577Z (6 months ago)
- Homepage:
- Size: 191 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-urweb - urweb-dequeue - Double ended queue over split list implementation (Algorithms and Data Structures)
README
# urweb-dequeue
Split list dequeue
```ocaml
datatype t a = Deq of (list a * list a)(* construct *)
fun cons[a]: a -> t a -> t a = fn x (Deq (l, r)) => Deq (x :: l, r)
fun snoc[a]: t a -> a -> t a = fn (Deq (l, r)) x => Deq (l, x :: r)(* deconstruct *)
fun viewL[a]: t a -> option (a * t a) = ...
fun viewR[a]: t a -> option (t a * a) = ...(* import/export *)
fun fromList[a]: list a -> t a = fn li =>
case li of
[] => Deq ([], [])
| _ => let val (prefix, suffix) = L.splitAt (L.length li `divide` 2) li
in Deq (prefix, L.rev suffix)
endval toList[a]: t a -> list a = fn (Deq (l, r)) => l `L.append` (L.rev r)
...
```### test task
tests lib/test/deq_UnitTest UrUnit assertions
```bash
urweb test1
./test1.exe -p 8082
browser http://localhost:8082
```
Every browser page refresh brings different random input data