From 44cd26f2cebd760a53aa4ff1b7779e718a101650 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 6 Apr 2025 22:45:02 -0400 Subject: Rename Array -> List in all code and docs --- examples/random/README.md | 8 ++++---- examples/random/random.tm | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'examples/random') diff --git a/examples/random/README.md b/examples/random/README.md index d9983ab7..183b9d0b 100644 --- a/examples/random/README.md +++ b/examples/random/README.md @@ -16,8 +16,8 @@ a Tomo program launches. ## RNG Functions This documentation provides details on RNG functions available in the API. -Arrays also have some methods which use RNG values: -`array.shuffle()`, `array.shuffled()`, `array.random()`, and `array.sample()`. +Lists also have some methods which use RNG values: +`list.shuffle()`, `list.shuffled()`, `list.random()`, and `list.sample()`. - [`func bool(rng: RNG, p: Num = 0.5 -> Bool)`](#bool) - [`func byte(rng: RNG -> Byte)`](#byte) @@ -75,7 +75,7 @@ A random byte (0-255). --- ### `bytes` -Generate an array of uniformly random bytes with the given length. +Generate a list of uniformly random bytes with the given length. ```tomo func bytes(rng: RNG, count: Int -> [Byte]) @@ -85,7 +85,7 @@ func bytes(rng: RNG, count: Int -> [Byte]) - `count`: The number of random bytes to return. **Returns:** -An array of length `count` random bytes with uniform random distribution (0-255). +A list of length `count` random bytes with uniform random distribution (0-255). **Example:** ```tomo diff --git a/examples/random/random.tm b/examples/random/random.tm index 13600b47..14b68d7f 100644 --- a/examples/random/random.tm +++ b/examples/random/random.tm @@ -21,7 +21,7 @@ func _os_random_bytes(count:Int64 -> [Byte]) return C_code:[Byte]( uint8_t *random_bytes = GC_MALLOC_ATOMIC(@count); getrandom(random_bytes, @count, 0); - (Array_t){.length=@count, .data=random_bytes, .stride=1, .atomic=1} + (List_t){.length=@count, .data=random_bytes, .stride=1, .atomic=1} ) struct RandomNumberGenerator(_chacha:chacha_ctx, _random_bytes:[Byte]=[]; secret) func new(seed:[Byte]?=none, -> @RandomNumberGenerator) @@ -36,7 +36,7 @@ struct RandomNumberGenerator(_chacha:chacha_ctx, _random_bytes:[Byte]=[]; secret // Immediately reinitialize for backtracking resistance chacha_keysetup(&@rng->_chacha, new_keystream); chacha_ivsetup(&@rng->_chacha, new_keystream + KEYSZ); - Array_t new_bytes = (Array_t){.data=GC_MALLOC_ATOMIC(1024), .length=1024, .stride=1, .atomic=1}; + List_t new_bytes = (List_t){.data=GC_MALLOC_ATOMIC(1024), .length=1024, .stride=1, .atomic=1}; memset(new_bytes.data, 0, new_bytes.length); chacha_encrypt_bytes(&@rng->_chacha, new_bytes.data, new_bytes.data, new_bytes.length); new_bytes @@ -65,7 +65,7 @@ struct RandomNumberGenerator(_chacha:chacha_ctx, _random_bytes:[Byte]=[]; secret count64 := Int64(count) buf := C_code:@Memory(GC_MALLOC_ATOMIC(@count64)) rng._fill_bytes(buf, count64) - return C_code:[Byte]((Array_t){.data=@buf, .stride=1, .atomic=1, .length=@count64}) + return C_code:[Byte]((List_t){.data=@buf, .stride=1, .atomic=1, .length=@count64}) func byte(rng:&RandomNumberGenerator -> Byte) byte : &Byte -- cgit v1.2.3