bright_id
stringlengths 11
257
| bright_doc
stringlengths 25
9.18M
| bright_split
stringclasses 8
values | scandi_id
stringlengths 3
7
| scandi_url
stringlengths 31
143
| scandi_title
stringlengths 1
79
| scandi_text
stringlengths 15
118k
| scandi_language
stringclasses 4
values | scandi_dist
float64 0.2
1.75
|
---|---|---|---|---|---|---|---|---|
Pony/builtin-String-.txt |
String¶
[Source]
A String is an ordered collection of bytes.
Strings don't specify an encoding.
Example usage of some common String methods:
actor Main
new create(env: Env) =>
try
// construct a new string
let str = "Hello"
// make an uppercased version
let str_upper = str.upper()
// make a reversed version
let str_reversed = str.reverse()
// add " world" to the end of our original string
let str_new = str.add(" world")
// count occurrences of letter "l"
let count = str_new.count("l")
// find first occurrence of letter "w"
let first_w = str_new.find("w") ?
// find first occurrence of letter "d"
let first_d = str_new.find("d") ?
// get substring capturing "world"
let substr = str_new.substring(first_w, first_d+1)
// clone substring
let substr_clone = substr.clone()
// print our substr
env.out.print(consume substr)
end
class val String is
Seq[U8 val] ref,
Comparable[String box] ref,
Stringable box
Implements¶
Seq[U8 val] ref
Comparable[String box] ref
Stringable box
Constructors¶
create¶
[Source]
An empty string. Enough space for len bytes is reserved.
new ref create(
len: USize val = 0)
: String ref^
Parameters¶
len: USize val = 0
Returns¶
String ref^
from_array¶
[Source]
Create a string from an array, reusing the underlying data pointer.
new val from_array(
data: Array[U8 val] val)
: String val^
Parameters¶
data: Array[U8 val] val
Returns¶
String val^
from_iso_array¶
[Source]
Create a string from an array, reusing the underlying data pointer
new iso from_iso_array(
data: Array[U8 val] iso)
: String iso^
Parameters¶
data: Array[U8 val] iso
Returns¶
String iso^
from_cpointer¶
[Source]
Return a string from binary pointer data without making a
copy. This must be done only with C-FFI functions that return
pony_alloc'd character arrays. If a null pointer is given then an
empty string is returned.
new ref from_cpointer(
str: Pointer[U8 val] ref,
len: USize val,
alloc: USize val = 0)
: String ref^
Parameters¶
str: Pointer[U8 val] ref
len: USize val
alloc: USize val = 0
Returns¶
String ref^
from_cstring¶
[Source]
Return a string from a pointer to a null-terminated cstring
without making a copy. The data is not copied. This must be done
only with C-FFI functions that return pony_alloc'd character
arrays. The pointer is scanned for the first null byte, which will
be interpreted as the null terminator. Note that the scan is
unbounded; the pointed to data must be null-terminated within
the allocated array to preserve memory safety. If a null pointer
is given then an empty string is returned.
new ref from_cstring(
str: Pointer[U8 val] ref)
: String ref^
Parameters¶
str: Pointer[U8 val] ref
Returns¶
String ref^
copy_cpointer¶
[Source]
Create a string by copying a fixed number of bytes from a pointer.
new ref copy_cpointer(
str: Pointer[U8 val] box,
len: USize val)
: String ref^
Parameters¶
str: Pointer[U8 val] box
len: USize val
Returns¶
String ref^
copy_cstring¶
[Source]
Create a string by copying a null-terminated C string. Note that
the scan is unbounded; the pointed to data must be null-terminated
within the allocated array to preserve memory safety. If a null
pointer is given then an empty string is returned.
new ref copy_cstring(
str: Pointer[U8 val] box)
: String ref^
Parameters¶
str: Pointer[U8 val] box
Returns¶
String ref^
from_utf32¶
[Source]
Create a UTF-8 string from a single UTF-32 code point.
new ref from_utf32(
value: U32 val)
: String ref^
Parameters¶
value: U32 val
Returns¶
String ref^
Public Functions¶
push_utf32¶
[Source]
Push a UTF-32 code point.
fun ref push_utf32(
value: U32 val)
: None val
Parameters¶
value: U32 val
Returns¶
None val
cpointer¶
[Source]
Returns a C compatible pointer to the underlying string allocation.
fun box cpointer(
offset: USize val = 0)
: Pointer[U8 val] tag
Parameters¶
offset: USize val = 0
Returns¶
Pointer[U8 val] tag
cstring¶
[Source]
Returns a C compatible pointer to a null-terminated version of the
string, safe to pass to an FFI function that doesn't accept a size
argument, expecting a null-terminator. If the underlying string
is already null terminated, this is returned; otherwise the string
is copied into a new, null-terminated allocation.
fun box cstring()
: Pointer[U8 val] tag
Returns¶
Pointer[U8 val] tag
array¶
[Source]
Returns an Array[U8] that reuses the underlying data pointer.
fun val array()
: Array[U8 val] val
Returns¶
Array[U8 val] val
iso_array¶
[Source]
Returns an Array[U8] iso that reuses the underlying data pointer.
fun iso iso_array()
: Array[U8 val] iso^
Returns¶
Array[U8 val] iso^
size¶
[Source]
Returns the length of the string data in bytes.
fun box size()
: USize val
Returns¶
USize val
codepoints¶
[Source]
Returns the number of unicode code points in the string between the two
offsets. Index range [from .. to) is half-open.
fun box codepoints(
from: ISize val = 0,
to: ISize val = call)
: USize val
Parameters¶
from: ISize val = 0
to: ISize val = call
Returns¶
USize val
space¶
[Source]
Returns the space available for data, not including the null terminator.
fun box space()
: USize val
Returns¶
USize val
reserve¶
[Source]
Reserve space for len bytes. An additional byte will be reserved for the
null terminator.
fun ref reserve(
len: USize val)
: None val
Parameters¶
len: USize val
Returns¶
None val
compact¶
[Source]
Try to remove unused space, making it available for garbage collection. The
request may be ignored. The string is returned to allow call chaining.
fun ref compact()
: None val
Returns¶
None val
recalc¶
[Source]
Recalculates the string length. This is only needed if the string is
changed via an FFI call. If a null terminator byte is not found within the
allocated length, the size will not be changed.
fun ref recalc()
: None val
Returns¶
None val
truncate¶
[Source]
Truncates the string at the minimum of len and space. Ensures there is a
null terminator. Does not check for null terminators inside the string.
Note that memory is not freed by this operation.
fun ref truncate(
len: USize val)
: None val
Parameters¶
len: USize val
Returns¶
None val
trim_in_place¶
[Source]
Trim the string to a portion of itself, covering from until to.
Unlike slice, the operation does not allocate a new string nor copy
elements.
fun ref trim_in_place(
from: USize val = 0,
to: USize val = call)
: None val
Parameters¶
from: USize val = 0
to: USize val = call
Returns¶
None val
trim¶
[Source]
Return a shared portion of this string, covering from until to.
Both the original and the new string are immutable, as they share memory.
The operation does not allocate a new string pointer nor copy elements.
fun val trim(
from: USize val = 0,
to: USize val = call)
: String val
Parameters¶
from: USize val = 0
to: USize val = call
Returns¶
String val
chop¶
[Source]
Chops the string in half at the split point requested and returns both
the left and right portions. The original string is trimmed in place and
returned as the left portion. If the split point is larger than the
string, the left portion is the original string and the right portion
is a new empty string.
Both strings are isolated and mutable, as they do not share memory.
The operation does not allocate a new string pointer nor copy elements.
fun iso chop(
split_point: USize val)
: (String iso^ , String iso^)
Parameters¶
split_point: USize val
Returns¶
(String iso^ , String iso^)
unchop¶
[Source]
Unchops two iso strings to return the original string they were chopped
from. Both input strings are isolated and mutable and were originally
chopped from a single string. This function checks that they are indeed two
strings chopped from the same original string and can be unchopped before
doing the unchopping and returning the unchopped string. If the two strings
cannot be unchopped it returns both strings without modifying them.
The operation does not allocate a new string pointer nor copy elements.
fun iso unchop(
b: String iso)
: ((String iso^ , String iso^) | String iso^)
Parameters¶
b: String iso
Returns¶
((String iso^ , String iso^) | String iso^)
is_null_terminated¶
[Source]
Return true if the string is null-terminated and safe to pass to an FFI
function that doesn't accept a size argument, expecting a null-terminator.
This method checks that there is a null byte just after the final position
of populated bytes in the string, but does not check for other null bytes
which may be present earlier in the content of the string.
If you need a null-terminated copy of this string, use the clone method.
fun box is_null_terminated()
: Bool val
Returns¶
Bool val
utf32¶
[Source]
Return a UTF32 representation of the character at the given offset and the
number of bytes needed to encode that character. If the offset does not
point to the beginning of a valid UTF8 encoding, return 0xFFFD (the unicode
replacement character) and a length of one. Raise an error if the offset is
out of bounds.
fun box utf32(
offset: ISize val)
: (U32 val , U8 val) ?
Parameters¶
offset: ISize val
Returns¶
(U32 val , U8 val) ?
apply¶
[Source]
Returns the i-th byte. Raise an error if the index is out of bounds.
fun box apply(
i: USize val)
: U8 val ?
Parameters¶
i: USize val
Returns¶
U8 val ?
update¶
[Source]
Change the i-th byte. Raise an error if the index is out of bounds.
fun ref update(
i: USize val,
value: U8 val)
: U8 val ?
Parameters¶
i: USize val
value: U8 val
Returns¶
U8 val ?
at_offset¶
[Source]
Returns the byte at the given offset. Raise an error if the offset is out
of bounds.
fun box at_offset(
offset: ISize val)
: U8 val ?
Parameters¶
offset: ISize val
Returns¶
U8 val ?
update_offset¶
[Source]
Changes a byte in the string, returning the previous byte at that offset.
Raise an error if the offset is out of bounds.
fun ref update_offset(
offset: ISize val,
value: U8 val)
: U8 val ?
Parameters¶
offset: ISize val
value: U8 val
Returns¶
U8 val ?
clone¶
[Source]
Returns a copy of the string. The resulting string is
null-terminated even if the original is not.
fun box clone()
: String iso^
Returns¶
String iso^
repeat_str¶
[Source]
Returns a copy of the string repeated num times with an optional
separator added inbetween repeats.
fun box repeat_str(
num: USize val = 1,
sep: String val = "")
: String iso^
Parameters¶
num: USize val = 1
sep: String val = ""
Returns¶
String iso^
mul¶
[Source]
Returns a copy of the string repeated num times.
fun box mul(
num: USize val)
: String iso^
Parameters¶
num: USize val
Returns¶
String iso^
find¶
[Source]
Return the index of the n-th instance of s in the string starting from the
beginning. Raise an error if there is no n-th occurrence of s or s is empty.
fun box find(
s: String box,
offset: ISize val = 0,
nth: USize val = 0)
: ISize val ?
Parameters¶
s: String box
offset: ISize val = 0
nth: USize val = 0
Returns¶
ISize val ?
rfind¶
[Source]
Return the index of n-th instance of s in the string starting from the
end. The offset represents the highest index to included in the search.
Raise an error if there is no n-th occurrence of s or s is empty.
fun box rfind(
s: String box,
offset: ISize val = call,
nth: USize val = 0)
: ISize val ?
Parameters¶
s: String box
offset: ISize val = call
nth: USize val = 0
Returns¶
ISize val ?
contains¶
[Source]
Returns true if contains s as a substring, false otherwise.
fun box contains(
s: String box,
offset: ISize val = 0,
nth: USize val = 0)
: Bool val
Parameters¶
s: String box
offset: ISize val = 0
nth: USize val = 0
Returns¶
Bool val
count¶
[Source]
Counts the non-overlapping occurrences of s in the string.
fun box count(
s: String box,
offset: ISize val = 0)
: USize val
Parameters¶
s: String box
offset: ISize val = 0
Returns¶
USize val
at¶
[Source]
Returns true if the substring s is present at the given offset.
fun box at(
s: String box,
offset: ISize val = 0)
: Bool val
Parameters¶
s: String box
offset: ISize val = 0
Returns¶
Bool val
delete¶
[Source]
Delete len bytes at the supplied offset, compacting the string in place.
fun ref delete(
offset: ISize val,
len: USize val = 1)
: None val
Parameters¶
offset: ISize val
len: USize val = 1
Returns¶
None val
substring¶
[Source]
Returns a substring. Index range [from .. to) is half-open.
Returns an empty string if nothing is in the range.
Note that this operation allocates a new string to be returned. For
similar operations that don't allocate a new string, see trim and
trim_in_place.
fun box substring(
from: ISize val,
to: ISize val = call)
: String iso^
Parameters¶
from: ISize val
to: ISize val = call
Returns¶
String iso^
lower¶
[Source]
Returns a lower case version of the string.
fun box lower()
: String iso^
Returns¶
String iso^
lower_in_place¶
[Source]
Transforms the string to lower case. Currently only knows ASCII case.
fun ref lower_in_place()
: None val
Returns¶
None val
upper¶
[Source]
Returns an upper case version of the string. Currently only knows ASCII
case.
fun box upper()
: String iso^
Returns¶
String iso^
upper_in_place¶
[Source]
Transforms the string to upper case.
fun ref upper_in_place()
: None val
Returns¶
None val
reverse¶
[Source]
Returns a reversed version of the string.
fun box reverse()
: String iso^
Returns¶
String iso^
reverse_in_place¶
[Source]
Reverses the byte order in the string. This needs to be changed to handle
UTF-8 correctly.
fun ref reverse_in_place()
: None val
Returns¶
None val
push¶
[Source]
Add a byte to the end of the string.
fun ref push(
value: U8 val)
: None val
Parameters¶
value: U8 val
Returns¶
None val
pop¶
[Source]
Remove a byte from the end of the string.
fun ref pop()
: U8 val ?
Returns¶
U8 val ?
unshift¶
[Source]
Adds a byte to the beginning of the string.
fun ref unshift(
value: U8 val)
: None val
Parameters¶
value: U8 val
Returns¶
None val
shift¶
[Source]
Removes a byte from the beginning of the string.
fun ref shift()
: U8 val ?
Returns¶
U8 val ?
append¶
[Source]
Append the elements from a sequence, starting from the given offset.
fun ref append(
seq: ReadSeq[U8 val] box,
offset: USize val = 0,
len: USize val = call)
: None val
Parameters¶
seq: ReadSeq[U8 val] box
offset: USize val = 0
len: USize val = call
Returns¶
None val
concat¶
[Source]
Add len iterated bytes to the end of the string, starting from the given
offset.
fun ref concat(
iter: Iterator[U8 val] ref,
offset: USize val = 0,
len: USize val = call)
: None val
Parameters¶
iter: Iterator[U8 val] ref
offset: USize val = 0
len: USize val = call
Returns¶
None val
clear¶
[Source]
Truncate the string to zero length.
fun ref clear()
: None val
Returns¶
None val
insert¶
[Source]
Returns a version of the string with the given string inserted at the given
offset.
fun box insert(
offset: ISize val,
that: String val)
: String iso^
Parameters¶
offset: ISize val
that: String val
Returns¶
String iso^
insert_in_place¶
[Source]
Inserts the given string at the given offset. Appends the string if the
offset is out of bounds.
fun ref insert_in_place(
offset: ISize val,
that: String box)
: None val
Parameters¶
offset: ISize val
that: String box
Returns¶
None val
insert_byte¶
[Source]
Inserts a byte at the given offset. Appends if the offset is out of bounds.
fun ref insert_byte(
offset: ISize val,
value: U8 val)
: None val
Parameters¶
offset: ISize val
value: U8 val
Returns¶
None val
cut¶
[Source]
Returns a version of the string with the given range deleted.
Index range [from .. to) is half-open.
fun box cut(
from: ISize val,
to: ISize val = call)
: String iso^
Parameters¶
from: ISize val
to: ISize val = call
Returns¶
String iso^
cut_in_place¶
[Source]
Cuts the given range out of the string.
Index range [from .. to) is half-open.
fun ref cut_in_place(
from: ISize val,
to: ISize val = call)
: None val
Parameters¶
from: ISize val
to: ISize val = call
Returns¶
None val
remove¶
[Source]
Remove all instances of s from the string. Returns the count of removed
instances.
fun ref remove(
s: String box)
: USize val
Parameters¶
s: String box
Returns¶
USize val
replace¶
[Source]
Replace up to n occurrences of from in this with to. If n is 0, all
occurrences will be replaced. Returns the count of replaced occurrences.
fun ref replace(
from: String box,
to: String box,
n: USize val = 0)
: USize val
Parameters¶
from: String box
to: String box
n: USize val = 0
Returns¶
USize val
split_by¶
[Source]
Split the string into an array of strings that are delimited by delim in
the original string. If n > 0, then the split count is limited to n.
Example:
let original: String = "<b><span>Hello!</span></b>"
let delimiter: String = "><"
let split_array: Array[String] = original.split_by(delimiter)
env.out.print("OUTPUT:")
for value in split_array.values() do
env.out.print(value)
end
// OUTPUT:
// <b
// span>Hello!</span
// b>
Adjacent delimiters result in a zero length entry in the array. For
example, "1CutCut2".split_by("Cut") => ["1", "", "2"].
An empty delimiter results in an array that contains a single element equal
to the whole string.
If you want to split the string with each individual character of delim,
use split.
fun box split_by(
delim: String val,
n: USize val = call)
: Array[String val] iso^
Parameters¶
delim: String val
n: USize val = call
Returns¶
Array[String val] iso^
split¶
[Source]
Split the string into an array of strings with any character in the
delimiter string. By default, the string is split with whitespace
characters. If n > 0, then the split count is limited to n.
Example:
let original: String = "name,job;department"
let delimiter: String = ".,;"
let split_array: Array[String] = original.split(delimiter)
env.out.print("OUTPUT:")
for value in split_array.values() do
env.out.print(value)
end
// OUTPUT:
// name
// job
// department
Adjacent delimiters result in a zero length entry in the array. For
example, "1,,2".split(",") => ["1", "", "2"].
If you want to split the string with the entire delimiter string delim,
use split_by.
fun box split(
delim: String val = "
",
n: USize val = 0)
: Array[String val] iso^
Parameters¶
delim: String val = "
"
n: USize val = 0
Returns¶
Array[String val] iso^
strip¶
[Source]
Remove all leading and trailing characters from the string that are in s.
fun ref strip(
s: String box = "
")
: None val
Parameters¶
s: String box = "
"
Returns¶
None val
rstrip¶
[Source]
Remove all trailing characters within the string that are in s. By default,
trailing whitespace is removed.
fun ref rstrip(
s: String box = "
")
: None val
Parameters¶
s: String box = "
"
Returns¶
None val
lstrip¶
[Source]
Remove all leading characters within the string that are in s. By default,
leading whitespace is removed.
fun ref lstrip(
s: String box = "
")
: None val
Parameters¶
s: String box = "
"
Returns¶
None val
add¶
[Source]
Return a string that is a concatenation of this and that.
fun box add(
that: String box)
: String iso^
Parameters¶
that: String box
Returns¶
String iso^
join¶
[Source]
Return a string that is a concatenation of the strings in data, using this
as a separator.
fun box join(
data: Iterator[Stringable box] ref)
: String iso^
Parameters¶
data: Iterator[Stringable box] ref
Returns¶
String iso^
compare¶
[Source]
Lexically compare two strings.
fun box compare(
that: String box)
: (Less val | Equal val | Greater val)
Parameters¶
that: String box
Returns¶
(Less val | Equal val | Greater val)
compare_sub¶
[Source]
Lexically compare at most n bytes of the substring of this starting at
offset with the substring of that starting at that_offset. The
comparison is case sensitive unless ignore_case is true.
If the substring of this is a proper prefix of the substring of that,
then this is Less than that. Likewise, if that is a proper prefix of
this, then this is Greater than that.
Both offset and that_offset can be negative, in which case the offsets
are computed from the end of the string.
If n + offset is greater than the length of this, or n + that_offset
is greater than the length of that, then the number of positions compared
will be reduced to the length of the longest substring.
Needs to be made UTF-8 safe.
fun box compare_sub(
that: String box,
n: USize val,
offset: ISize val = 0,
that_offset: ISize val = 0,
ignore_case: Bool val = false)
: (Less val | Equal val | Greater val)
Parameters¶
that: String box
n: USize val
offset: ISize val = 0
that_offset: ISize val = 0
ignore_case: Bool val = false
Returns¶
(Less val | Equal val | Greater val)
eq¶
[Source]
Returns true if the two strings have the same contents.
fun box eq(
that: String box)
: Bool val
Parameters¶
that: String box
Returns¶
Bool val
lt¶
[Source]
Returns true if this is lexically less than that. Needs to be made UTF-8
safe.
fun box lt(
that: String box)
: Bool val
Parameters¶
that: String box
Returns¶
Bool val
le¶
[Source]
Returns true if this is lexically less than or equal to that. Needs to be
made UTF-8 safe.
fun box le(
that: String box)
: Bool val
Parameters¶
that: String box
Returns¶
Bool val
offset_to_index¶
[Source]
fun box offset_to_index(
i: ISize val)
: USize val
Parameters¶
i: ISize val
Returns¶
USize val
bool¶
[Source]
fun box bool()
: Bool val ?
Returns¶
Bool val ?
i8¶
[Source]
fun box i8(
base: U8 val = 0)
: I8 val ?
Parameters¶
base: U8 val = 0
Returns¶
I8 val ?
i16¶
[Source]
fun box i16(
base: U8 val = 0)
: I16 val ?
Parameters¶
base: U8 val = 0
Returns¶
I16 val ?
i32¶
[Source]
fun box i32(
base: U8 val = 0)
: I32 val ?
Parameters¶
base: U8 val = 0
Returns¶
I32 val ?
i64¶
[Source]
fun box i64(
base: U8 val = 0)
: I64 val ?
Parameters¶
base: U8 val = 0
Returns¶
I64 val ?
i128¶
[Source]
fun box i128(
base: U8 val = 0)
: I128 val ?
Parameters¶
base: U8 val = 0
Returns¶
I128 val ?
ilong¶
[Source]
fun box ilong(
base: U8 val = 0)
: ILong val ?
Parameters¶
base: U8 val = 0
Returns¶
ILong val ?
isize¶
[Source]
fun box isize(
base: U8 val = 0)
: ISize val ?
Parameters¶
base: U8 val = 0
Returns¶
ISize val ?
u8¶
[Source]
fun box u8(
base: U8 val = 0)
: U8 val ?
Parameters¶
base: U8 val = 0
Returns¶
U8 val ?
u16¶
[Source]
fun box u16(
base: U8 val = 0)
: U16 val ?
Parameters¶
base: U8 val = 0
Returns¶
U16 val ?
u32¶
[Source]
fun box u32(
base: U8 val = 0)
: U32 val ?
Parameters¶
base: U8 val = 0
Returns¶
U32 val ?
u64¶
[Source]
fun box u64(
base: U8 val = 0)
: U64 val ?
Parameters¶
base: U8 val = 0
Returns¶
U64 val ?
u128¶
[Source]
fun box u128(
base: U8 val = 0)
: U128 val ?
Parameters¶
base: U8 val = 0
Returns¶
U128 val ?
ulong¶
[Source]
fun box ulong(
base: U8 val = 0)
: ULong val ?
Parameters¶
base: U8 val = 0
Returns¶
ULong val ?
usize¶
[Source]
fun box usize(
base: U8 val = 0)
: USize val ?
Parameters¶
base: U8 val = 0
Returns¶
USize val ?
read_int[A: ((I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Integer[A] val)]¶
[Source]
Read an integer from the specified location in this string. The integer
value read and the number of bytes consumed are reported.
The base parameter specifies the base to use, 0 indicates using the prefix,
if any, to detect base 2, 10 or 16.
If no integer is found at the specified location, then (0, 0) is returned,
since no characters have been used.
An integer out of range for the target type throws an error.
A leading minus is allowed for signed integer types.
Underscore characters are allowed throughout the integer and are ignored.
fun box read_int[A: ((I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val) & Integer[A] val)](
offset: ISize val = 0,
base: U8 val = 0)
: (A , USize val) ?
Parameters¶
offset: ISize val = 0
base: U8 val = 0
Returns¶
(A , USize val) ?
f32¶
[Source]
Convert this string starting at the given offset
to a 32-bit floating point number (F32).
This method errors if this string cannot be parsed to a float,
if the result would over- or underflow,
the offset exceeds the size of this string or
there are leftover characters in the string after conversion.
Examples:
"1.5".f32()? == F32(1.5)
"1.19208e-07".f32()? == F32(1.19208e-07)
"NaN".f32()?.nan() == true
fun box f32(
offset: ISize val = 0)
: F32 val ?
Parameters¶
offset: ISize val = 0
Returns¶
F32 val ?
f64¶
[Source]
Convert this string starting at the given offset
to a 64-bit floating point number (F64).
This method errors if this string cannot be parsed to a float,
if the result would over- or underflow,
the offset exceeds the size of this string or
there are leftover characters in the string after conversion.
Examples:
"1.5".f64()? == F64(1.5)
"1.19208e-07".f64()? == F64(1.19208e-07)
"Inf".f64()?.infinite() == true
fun box f64(
offset: ISize val = 0)
: F64 val ?
Parameters¶
offset: ISize val = 0
Returns¶
F64 val ?
hash¶
[Source]
fun box hash()
: USize val
Returns¶
USize val
hash64¶
[Source]
fun box hash64()
: U64 val
Returns¶
U64 val
string¶
[Source]
fun box string()
: String iso^
Returns¶
String iso^
values¶
[Source]
Return an iterator over the bytes in the string.
fun box values()
: StringBytes ref^
Returns¶
StringBytes ref^
runes¶
[Source]
Return an iterator over the codepoints in the string.
fun box runes()
: StringRunes ref^
Returns¶
StringRunes ref^
ge¶
[Source]
fun box ge(
that: String box)
: Bool val
Parameters¶
that: String box
Returns¶
Bool val
gt¶
[Source]
fun box gt(
that: String box)
: Bool val
Parameters¶
that: String box
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: String box)
: Bool val
Parameters¶
that: String box
Returns¶
Bool val
| pony | 205617 | https://no.wikipedia.org/wiki/MOD11 | MOD11 | MOD11 (Modulus11) er en kontrollsifferalgoritme som blant annet benyttes for å validere kontonumre i norske banker, organisasjonsnummer og det siste sifferet i norske fødselsnummer. (Norske fødselsnummer har to kontrollsifre, det nest siste er også et modulo 11-kontrollsiffer, men ved beregningen av dette benyttes det multiplikatorer i en annen og uregelmessig rekkefølge).
Bakgrunn
Kontrollsiffer benyttes for å oppdage feil ved inntasting av f.eks. KID, kontonumre og fødselsnumre. Det benyttes i all hovedsak to algoritmer for dette, MOD10 og MOD11. Disse kontrollsifrene kontrolleres maskinelt ved OCR-lesing i skranken hos banker. En del IT-systemer kontrollerer også disse kontrollsifre for å sikre at brukere ikke har tastet feil. Dette inkluderer nettbanker og lønnssystemer.
Dersom to eller flere siffer i det inntastede felt er feil, øker sjansen for at kontrollsifferet beregnes til det samme, og at feilen ikke oppdages. Den vil likevel ikke være mer enn om lag 9 % for MOD11 – og 10 % for MOD10. Dersom en tilfeldig tallrekke kontrolleres, er sannsynligheten om lag 9 % for at siste siffer stemmer med kontrollsiffer beregningen (MOD11 bruker også tegnet «-» som et kontrolltegn, så det blir elleve varianter).
Denne kontrollsifferalgoritmen er også designet til å oppdage ombytting av sifre. Det er noe økt sjanse for at brukere taster inn f.eks. en KID der to sifre har byttet plass. Derfor brukes et prinsipp med varierende vekttall for hvert siffer i algoritmen nedenfor. I modulus-10 kan det oppdages om to påfølgende siffer har byttet plass, men ikke første og siste i gruppe på tre. Modulus11 vil også oppdage det.
Beregning av kontrollsiffer med Modulus11
Et tenkt kontonummer er 1234.56.78903. Det siste sifferet i kontonummeret er et kontrollsiffer. I dette eksempelet er kontrollsifferet 3. Kontonummeret uten kontrollsiffer (og uten skilletegn) er 1234567890.
Hvert siffer i eksempelet over multipliseres med vekttallene 2,3,4,5,6,7,2,3,4,5 (eventuelt videre ,6,7,2,3 og så videre for tall med flere sifre), regnet fra høyre mot venstre.
0 × 2 = 0
9 × 3 = 27
8 × 4 = 32
7 × 5 = 35
6 × 6 = 36
5 × 7 = 35
4 x 2 = 8
3 x 3 = 9
2 x 4 = 8
1 x 5 = 5
Summen er 0 + 27 + 32 + 35 + 36 + 35 + 8 + 9 + 8 + 5 = 195.
Kontrollsifferet blir nå det tallet som må legges til summen for å få et tall som er delelig med 11.
Summen divideres med 11 og vi noterer «resten» som blir 8 i dette tilfellet. Denne resten trekkes fra 11 og vi får 3 som blir kontrollsifferet.
11 - 8 = kontrollsifferet 3
Komplett og gyldig kontonummer i dette eksempelet er derfor 1234.56.78903.
Dersom summen er delelig med 11 blir også resten 0 og kontrollsifferet 0. Dersom «resten» ved divisjonen blir 1 skal «kontrollsifferet» ha tallverdien 10, da benyttes isteden et minustegn (eller bindestrek) istedenfor kontrollsifferet. Imidlertid gjelder for kontonumre (og også for personnummer) at slike tall isteden skal forkastes slik at for de typene tall kan kontrollsiffer «-» aldri forekomme.
Implementasjoner i forskjellige programmeringspråk
C#
public static bool ValidateMod11(string bankAccountNumber)
{
var normalized = Regex.Replace(bankAccountNumber, @"[\s.]+", string.Empty);
if (normalized.Length != 11)
{
return false;
}
var weights = new[] { 5, 4, 3, 2, 7, 6, 5, 4, 3, 2 };
var sum = 0;
for (var i = 0; i < 10; i++)
{
sum += int.Parse(normalized[i].ToString()) * weights[i];
}
var remainder = sum % 11;
var controlDigit = int.Parse(normalized[10].ToString());
return controlDigit == (remainder == 0 ? 0 : 11 - remainder);
}
JavaScript
function validateKontonummerMod11(kontonummer) {
const weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
const kontonummerWithoutSpacesAndPeriods = kontonummer.replace(/[\s.]+/g, '');
if (kontonummerWithoutSpacesAndPeriods.length !== 11) {
return false;
} else {
const sjekksiffer = parseInt(kontonummerWithoutSpacesAndPeriods.charAt(10), 10);
const kontonummerUtenSjekksiffer = kontonummerWithoutSpacesAndPeriods.substring(0, 10);
let sum = 0;
for (let index = 0; index < 10; index++) {
sum += parseInt(kontonummerUtenSjekksiffer.charAt(index), 10) * weights[index];
}
const remainder = sum % 11;
return sjekksiffer === (remainder === 0 ? 0 : 11 - remainder);
}
}
Python
def kid_mod11_wiki(a):
cross = sum([int(val)*[2,3,4,5,6,7][idx%6] for idx,val in enumerate(list(str(a))[::-1])])
return "%s%s" % (a,cross % 11 == 10 and '-' or 11-(cross % 11))
Java
public class KontonummerValidator {
public static boolean gyldigKontonummer(String kontonr) {
// Fjern whitespace og punktum fra kontonummer (enkelte liker å formatere kontonummer med 1234.56.78903)
kontonr = StringUtils.remove(kontonr, ' ');
kontonr = StringUtils.remove(kontonr, '.');
// Skal inneholde 11 siffer og kun tall
if (kontonr.length() != 11 || !StringUtils.isNumeric(kontonr)) {
return false;
}
int sisteSiffer = Character.getNumericValue(kontonr.charAt(kontonr.length() - 1));
return getCheckDigit(kontonr) == sisteSiffer;
}
private static int getCheckDigit(String number) {
int lastIndex = number.length() - 1;
int sum = 0;
for (int i = 0; i < lastIndex; i++) {
sum += Character.getNumericValue(number.charAt(i)) * getWeightNumber(i);
}
int remainder = sum % 11;
return getCheckDigitFromRemainder(remainder);
}
private static int getWeightNumber(int i) {
return 7 - (i + 2) % 6;
}
private static int getCheckDigitFromRemainder(int remainder) {
switch (remainder) {
case 0:
return 0;
default:
return 11 - remainder;
}
}
}
Kotlin
fun validMod11(cid: String): Boolean {
val controlDigit = cid[cid.length - 1].toString()
val controlSumNumbers = listOf(
2, 3, 4, 5, 6, 7,
2, 3, 4, 5, 6, 7,
2, 3, 4, 5, 6, 7,
2, 3, 4, 5, 6, 7
)
val number = cid.subSequence(0, cid.length - 1).reversed().toString()
var sum = 0
for(i in number.indices) {
sum += number[i].toString().toInt() * controlSumNumbers[i]
}
val output = when (val sumResult = 11 - sum % 11) {
11 -> "0"
10 -> "-"
else -> sumResult.toString()
}
return output == controlDigit
}
Se også
MOD10
Referanser
Programmering | norwegian_bokmål | 0.863193 |
Pony/assert-Fact-.txt |
Fact¶
[Source]
This is an assertion that is always enabled. If the test is false, it will
print any supplied error message to stderr and raise an error.
primitive val Fact
Constructors¶
create¶
[Source]
new val create()
: Fact val^
Returns¶
Fact val^
Public Functions¶
apply¶
[Source]
fun box apply(
test: Bool val,
msg: String val = "")
: None val ?
Parameters¶
test: Bool val
msg: String val = ""
Returns¶
None val ?
eq¶
[Source]
fun box eq(
that: Fact val)
: Bool val
Parameters¶
that: Fact val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: Fact val)
: Bool val
Parameters¶
that: Fact val
Returns¶
Bool val
| pony | 835512 | https://sv.wikipedia.org/wiki/Common%20Type%20System | Common Type System | Common Type System (CTS) är en standard som specificerar hur datatyper ter sig i ett datorminne. Målet är att låta program som är skrivna i olika programspråk lätt ska kunna utbyta information med varandra. I ett programspråk kan en typ beskrivas som en definition av en mängd med värden (till exempel heltal mellan 0 och 10), och de tillåtna operationerna som kan utföras med dessa värden.
Specifikationen för CTS är en del av Ecma standard 335, "Common Language Infrastructure (CLI) Partitions I to VI." CLI och CTS skapades av Microsoft, och Microsoft .NET framework är en implementation av standarden.
Typkategorier
CTS stödjer följande två typer:
Värdetyper
En värdetyp innehåller direkt sitt värde, och allokeras på stacken eller inuti en struktur. Värdetyper kan vara förimplementerade av runtime eller definierade av användaren. De primitiva typerna (int, char, bool osv.) och strukturer är värdetyper.
Referenstyper
En referenstyp innehåller referensen till värdets plats i minnet, och är allokerade på heapen. Variabler är som pekare och är inte bundna till något specifikt objekt. Klasser, gränssnitt, strängar, delegater, boxade värdetyper och arrayer är exempel på referenstyper.
Följande exempel visar skillnaderna mellan värdetyper och referenstyper.
Imports System
Class Class1
Public Value As Integer = 0
End Class 'Class1
Class Test
Shared Sub Main()
Dim val1 As Integer = 0
Dim val2 As Integer = val1
val2 = 123
Dim ref1 As New Class1()
Dim ref2 As Class1 = ref1
ref2.Value = 123
Console.WriteLine("Värden: {0}, {1}", val1, val2)
Console.WriteLine("Referenser: {0}, {1}", ref1.Value, ref2.Value)
End Sub 'Main
End Class 'Test
Utskriften från exemplet ovan
Värden: 0, 123
Referenser: 123, 123
Boxning
Konvertering av värdetyp till en referenstyp kallas boxning. Detta är möjligt då värdetyper och referenstyper båda ärver basklassen System.Object.
Int32 x = 10;
object o = x ; // Implicit boxning
Console.WriteLine("The Object o = {0}",o); // skriver ut 10
Men en Int32 kan också bli explicit boxad:
Int32 x = 10;
object o = (object) x; // Explicit boxning
Console.WriteLine("The object o = {0}",o); // skriver ut 10
På liknande sätt kan den bli konverterad tillbaka till en värdetyp.
Int32 x = 5;
object o = x; // Implicit boxning
x = o; // Implicit utboxning
Se även
Common Language Infrastructure
Källor
Artikel på engelskspråkiga Wikipedia
Externa länkar
Microsoft developer's guide describing the CTS
built-in types in the .NET Framework
.NET Framework | swedish | 0.832662 |
Pony/standard-library.txt | # Standard Library
The Pony standard library is a collection of packages that can each be used as needed to provide a variety of functionality. For example, the __files__ package provides file access and the __collections__ package provides generic lists, maps, sets and so on.
There is also a special package in the standard library called __builtin__. This contains various types that the compiler has to treat specially and are so common that all Pony code needs to know about them. All Pony source files have an implicit `use "builtin"` command. This means all the types defined in the package builtin are automatically available in the type namespace of all Pony source files.
Documentation for the standard library is [available online](https://stdlib.ponylang.io/)
| pony | 2285201 | https://sv.wikipedia.org/wiki/Philautus%20pallidipes | Philautus pallidipes | Philautus pallidipes är en groddjursart som först beskrevs av Barbour 1908. Philautus pallidipes ingår i släktet Philautus och familjen trädgrodor. IUCN kategoriserar arten globalt som sårbar. Inga underarter finns listade i Catalogue of Life.
Källor
Externa länkar
Trädgrodor
pallidipes | swedish | 1.498453 |
Pony/collections-persistent-VecKeys-.txt |
VecKeys[A: Any #share]¶
[Source]
class ref VecKeys[A: Any #share]
Constructors¶
create¶
[Source]
new ref create(
v: Vec[A] val)
: VecKeys[A] ref^
Parameters¶
v: Vec[A] val
Returns¶
VecKeys[A] ref^
Public Functions¶
has_next¶
[Source]
fun box has_next()
: Bool val
Returns¶
Bool val
next¶
[Source]
fun ref next()
: USize val ?
Returns¶
USize val ?
| pony | 835512 | https://sv.wikipedia.org/wiki/Common%20Type%20System | Common Type System | Common Type System (CTS) är en standard som specificerar hur datatyper ter sig i ett datorminne. Målet är att låta program som är skrivna i olika programspråk lätt ska kunna utbyta information med varandra. I ett programspråk kan en typ beskrivas som en definition av en mängd med värden (till exempel heltal mellan 0 och 10), och de tillåtna operationerna som kan utföras med dessa värden.
Specifikationen för CTS är en del av Ecma standard 335, "Common Language Infrastructure (CLI) Partitions I to VI." CLI och CTS skapades av Microsoft, och Microsoft .NET framework är en implementation av standarden.
Typkategorier
CTS stödjer följande två typer:
Värdetyper
En värdetyp innehåller direkt sitt värde, och allokeras på stacken eller inuti en struktur. Värdetyper kan vara förimplementerade av runtime eller definierade av användaren. De primitiva typerna (int, char, bool osv.) och strukturer är värdetyper.
Referenstyper
En referenstyp innehåller referensen till värdets plats i minnet, och är allokerade på heapen. Variabler är som pekare och är inte bundna till något specifikt objekt. Klasser, gränssnitt, strängar, delegater, boxade värdetyper och arrayer är exempel på referenstyper.
Följande exempel visar skillnaderna mellan värdetyper och referenstyper.
Imports System
Class Class1
Public Value As Integer = 0
End Class 'Class1
Class Test
Shared Sub Main()
Dim val1 As Integer = 0
Dim val2 As Integer = val1
val2 = 123
Dim ref1 As New Class1()
Dim ref2 As Class1 = ref1
ref2.Value = 123
Console.WriteLine("Värden: {0}, {1}", val1, val2)
Console.WriteLine("Referenser: {0}, {1}", ref1.Value, ref2.Value)
End Sub 'Main
End Class 'Test
Utskriften från exemplet ovan
Värden: 0, 123
Referenser: 123, 123
Boxning
Konvertering av värdetyp till en referenstyp kallas boxning. Detta är möjligt då värdetyper och referenstyper båda ärver basklassen System.Object.
Int32 x = 10;
object o = x ; // Implicit boxning
Console.WriteLine("The Object o = {0}",o); // skriver ut 10
Men en Int32 kan också bli explicit boxad:
Int32 x = 10;
object o = (object) x; // Explicit boxning
Console.WriteLine("The object o = {0}",o); // skriver ut 10
På liknande sätt kan den bli konverterad tillbaka till en värdetyp.
Int32 x = 5;
object o = x; // Implicit boxning
x = o; // Implicit utboxning
Se även
Common Language Infrastructure
Källor
Artikel på engelskspråkiga Wikipedia
Externa länkar
Microsoft developer's guide describing the CTS
built-in types in the .NET Framework
.NET Framework | swedish | 0.832662 |
Pony/format-FormatFixLarge-.txt |
FormatFixLarge¶
[Source]
primitive val FormatFixLarge is
FormatSpec val
Implements¶
FormatSpec val
Constructors¶
create¶
[Source]
new val create()
: FormatFixLarge val^
Returns¶
FormatFixLarge val^
Public Functions¶
eq¶
[Source]
fun box eq(
that: FormatFixLarge val)
: Bool val
Parameters¶
that: FormatFixLarge val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FormatFixLarge val)
: Bool val
Parameters¶
that: FormatFixLarge val
Returns¶
Bool val
| pony | 57243 | https://da.wikipedia.org/wiki/V%C3%A6rdim%C3%A6ngde | Værdimængde | En funktions værdimængde eller billedmængde er den mængde af værdier, som en funktion er i stand til at returnere. Funktionen f's værdimængde skrives som Vm(f).
Ved illustrering af en reel funktion af én reel variabel i et koordinatsystem sættes værdimængden konventionelt op ad y-aksen, også kaldet 2.-aksen.
Eksempler
Sinusfunktionen og cosinusfunktionen har begge værdimængden [-1; 1], og hvis (hvis x er et reelt tal).
Referencer
Se også
Definitionsmængde
Dispositionsmængde
Bøger
Holth, Klaus m.fl. (1987): Matematik Grundbog 1. Forlaget Trip, Vejle.
Hebsgaard, Thomas m.fl. (1989): Matematik Grundbog 2. Forlaget Trip, Vejle.
Mængdelære | danish | 0.979531 |
Pony/collections-HashMap-.txt |
HashMap[K: K, V: V, H: HashFunction[K] val]¶
[Source]
A quadratic probing hash map. Resize occurs at a load factor of 0.75. A
resized map has 2 times the space. The hash function can be plugged in to the
type to create different kinds of maps.
class ref HashMap[K: K, V: V, H: HashFunction[K] val]
Constructors¶
create¶
[Source]
Create an array with space for prealloc elements without triggering a
resize. Defaults to 6.
new ref create(
prealloc: USize val = 6)
: HashMap[K, V, H] ref^
Parameters¶
prealloc: USize val = 6
Returns¶
HashMap[K, V, H] ref^
Public Functions¶
size¶
[Source]
The number of items in the map.
fun box size()
: USize val
Returns¶
USize val
space¶
[Source]
The available space in the map. Resize will happen when
size / space >= 0.75.
fun box space()
: USize val
Returns¶
USize val
apply¶
[Source]
Gets a value from the map. Raises an error if no such item exists.
fun box apply(
key: box->K!)
: this->V ?
Parameters¶
key: box->K!
Returns¶
this->V ?
update¶
[Source]
Sets a value in the map. Returns the old value if there was one, otherwise
returns None. If there was no previous value, this may trigger a resize.
fun ref update(
key: K,
value: V)
: (V^ | None val)
Parameters¶
key: K
value: V
Returns¶
(V^ | None val)
upsert¶
[Source]
Combines a provided value with the current value for the provided key
using the provided function. If the provided key has not been added to
the map yet, it sets its value to the provided value and ignores the
provided function.
As a simple example, say we had a map with I64 values and we wanted to
add 4 to the current value for key "test", which let's say is currently 2.
We call
m.upsert("test", 4, {(current, provided) => current + provided })
This changes the value associated with "test" to 6.
If we have not yet added the key "new-key" to the map and we call
m.upsert("new-key", 4, {(current, provided) => current + provided })
then "new-key" is added to the map with a value of 4.
Returns the value that we set the key to
fun ref upsert(
key: K,
value: V,
f: {(V, V): V^}[K, V, H] box)
: V!
Parameters¶
key: K
value: V
f: {(V, V): V^}[K, V, H] box
Returns¶
V!
insert¶
[Source]
Set a value in the map. Returns the new value, allowing reuse.
fun ref insert(
key: K,
value: V)
: V!
Parameters¶
key: K
value: V
Returns¶
V!
insert_if_absent¶
[Source]
Set a value in the map if the key doesn't already exist in the Map.
Saves an extra lookup when doing a pattern like:
if not my_map.contains(my_key) then
my_map(my_key) = my_value
end
Returns the value, the same as insert, allowing 'insert_if_absent'
to be used as a drop-in replacement for insert.
fun ref insert_if_absent(
key: K,
value: V)
: V!
Parameters¶
key: K
value: V
Returns¶
V!
remove¶
[Source]
Delete a value from the map and return it. Raises an error if there was no
value for the given key.
fun ref remove(
key: box->K!)
: (K^ , V^) ?
Parameters¶
key: box->K!
Returns¶
(K^ , V^) ?
get_or_else¶
[Source]
Get the value associated with provided key if present. Otherwise,
return the provided alternate value.
fun box get_or_else(
key: box->K!,
alt: this->V)
: this->V
Parameters¶
key: box->K!
alt: this->V
Returns¶
this->V
contains¶
[Source]
Checks whether the map contains the key k
fun box contains(
k: box->K!)
: Bool val
Parameters¶
k: box->K!
Returns¶
Bool val
concat¶
[Source]
Add K, V pairs from the iterator to the map.
fun ref concat(
iter: Iterator[(K^ , V^)] ref)
: None val
Parameters¶
iter: Iterator[(K^ , V^)] ref
Returns¶
None val
add[optional H2: HashFunction[this->K!] val]¶
[Source]
This with the new (key, value) mapping.
fun box add[optional H2: HashFunction[this->K!] val](
key: this->K!,
value: this->V!)
: HashMap[this->K!, this->V!, H2] ref^
Parameters¶
key: this->K!
value: this->V!
Returns¶
HashMap[this->K!, this->V!, H2] ref^
sub[optional H2: HashFunction[this->K!] val]¶
[Source]
This without the given key.
fun box sub[optional H2: HashFunction[this->K!] val](
key: this->K!)
: HashMap[this->K!, this->V!, H2] ref^
Parameters¶
key: this->K!
Returns¶
HashMap[this->K!, this->V!, H2] ref^
next_index¶
[Source]
Given an index, return the next index that has a populated key and value.
Raise an error if there is no next populated index.
fun box next_index(
prev: USize val = call)
: USize val ?
Parameters¶
prev: USize val = call
Returns¶
USize val ?
index¶
[Source]
Returns the key and value at a given index.
Raise an error if the index is not populated.
fun box index(
i: USize val)
: (this->K , this->V) ?
Parameters¶
i: USize val
Returns¶
(this->K , this->V) ?
compact¶
[Source]
Minimise the memory used for the map.
fun ref compact()
: None val
Returns¶
None val
clone[optional H2: HashFunction[this->K!] val]¶
[Source]
Create a clone. The key and value types may be different due to aliasing
and viewpoint adaptation.
fun box clone[optional H2: HashFunction[this->K!] val]()
: HashMap[this->K!, this->V!, H2] ref^
Returns¶
HashMap[this->K!, this->V!, H2] ref^
clear¶
[Source]
Remove all entries.
fun ref clear()
: None val
Returns¶
None val
keys¶
[Source]
Return an iterator over the keys.
fun box keys()
: MapKeys[K, V, H, this->HashMap[K, V, H] ref] ref^
Returns¶
MapKeys[K, V, H, this->HashMap[K, V, H] ref] ref^
values¶
[Source]
Return an iterator over the values.
fun box values()
: MapValues[K, V, H, this->HashMap[K, V, H] ref] ref^
Returns¶
MapValues[K, V, H, this->HashMap[K, V, H] ref] ref^
pairs¶
[Source]
Return an iterator over the keys and values.
fun box pairs()
: MapPairs[K, V, H, this->HashMap[K, V, H] ref] ref^
Returns¶
MapPairs[K, V, H, this->HashMap[K, V, H] ref] ref^
| pony | 835512 | https://sv.wikipedia.org/wiki/Common%20Type%20System | Common Type System | Common Type System (CTS) är en standard som specificerar hur datatyper ter sig i ett datorminne. Målet är att låta program som är skrivna i olika programspråk lätt ska kunna utbyta information med varandra. I ett programspråk kan en typ beskrivas som en definition av en mängd med värden (till exempel heltal mellan 0 och 10), och de tillåtna operationerna som kan utföras med dessa värden.
Specifikationen för CTS är en del av Ecma standard 335, "Common Language Infrastructure (CLI) Partitions I to VI." CLI och CTS skapades av Microsoft, och Microsoft .NET framework är en implementation av standarden.
Typkategorier
CTS stödjer följande två typer:
Värdetyper
En värdetyp innehåller direkt sitt värde, och allokeras på stacken eller inuti en struktur. Värdetyper kan vara förimplementerade av runtime eller definierade av användaren. De primitiva typerna (int, char, bool osv.) och strukturer är värdetyper.
Referenstyper
En referenstyp innehåller referensen till värdets plats i minnet, och är allokerade på heapen. Variabler är som pekare och är inte bundna till något specifikt objekt. Klasser, gränssnitt, strängar, delegater, boxade värdetyper och arrayer är exempel på referenstyper.
Följande exempel visar skillnaderna mellan värdetyper och referenstyper.
Imports System
Class Class1
Public Value As Integer = 0
End Class 'Class1
Class Test
Shared Sub Main()
Dim val1 As Integer = 0
Dim val2 As Integer = val1
val2 = 123
Dim ref1 As New Class1()
Dim ref2 As Class1 = ref1
ref2.Value = 123
Console.WriteLine("Värden: {0}, {1}", val1, val2)
Console.WriteLine("Referenser: {0}, {1}", ref1.Value, ref2.Value)
End Sub 'Main
End Class 'Test
Utskriften från exemplet ovan
Värden: 0, 123
Referenser: 123, 123
Boxning
Konvertering av värdetyp till en referenstyp kallas boxning. Detta är möjligt då värdetyper och referenstyper båda ärver basklassen System.Object.
Int32 x = 10;
object o = x ; // Implicit boxning
Console.WriteLine("The Object o = {0}",o); // skriver ut 10
Men en Int32 kan också bli explicit boxad:
Int32 x = 10;
object o = (object) x; // Explicit boxning
Console.WriteLine("The object o = {0}",o); // skriver ut 10
På liknande sätt kan den bli konverterad tillbaka till en värdetyp.
Int32 x = 5;
object o = x; // Implicit boxning
x = o; // Implicit utboxning
Se även
Common Language Infrastructure
Källor
Artikel på engelskspråkiga Wikipedia
Externa länkar
Microsoft developer's guide describing the CTS
built-in types in the .NET Framework
.NET Framework | swedish | 0.832662 |
Pony/builtin-ArrayValues-.txt |
ArrayValues[A: A, B: Array[A] #read]¶
[Source]
class ref ArrayValues[A: A, B: Array[A] #read] is
Iterator[B->A] ref
Implements¶
Iterator[B->A] ref
Constructors¶
create¶
[Source]
new ref create(
array: B)
: ArrayValues[A, B] ref^
Parameters¶
array: B
Returns¶
ArrayValues[A, B] ref^
Public Functions¶
has_next¶
[Source]
fun box has_next()
: Bool val
Returns¶
Bool val
next¶
[Source]
fun ref next()
: B->A ?
Returns¶
B->A ?
rewind¶
[Source]
fun ref rewind()
: ArrayValues[A, B] ref
Returns¶
ArrayValues[A, B] ref
| pony | 2361760 | https://sv.wikipedia.org/wiki/Anolis%20baleatus | Anolis baleatus | Anolis baleatus är en ödleart som beskrevs av Cope 1864. Anolis baleatus ingår i släktet anolisar, och familjen Polychrotidae.
Underarter
Arten delas in i följande underarter:
A. b. baleatus
A. b. altager
A. b. caeruleolatus
A. b. fraudator
A. b. lineatacervix
A. b. litorisilva
A. b. multistruppus
A. b. samanae
A. b. scelestus
A. b. sublimis
Källor
Externa länkar
Anolisar
baleatus | swedish | 0.991421 |
Pony/files-FileStat-.txt |
FileStat¶
[Source]
primitive val FileStat
Constructors¶
create¶
[Source]
new val create()
: FileStat val^
Returns¶
FileStat val^
Public Functions¶
value¶
[Source]
fun box value()
: U32 val
Returns¶
U32 val
eq¶
[Source]
fun box eq(
that: FileStat val)
: Bool val
Parameters¶
that: FileStat val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FileStat val)
: Bool val
Parameters¶
that: FileStat val
Returns¶
Bool val
| pony | 3268672 | https://sv.wikipedia.org/wiki/Poecilanthrax%20efrenus | Poecilanthrax efrenus | Poecilanthrax efrenus är en tvåvingeart som först beskrevs av Daniel William Coquillett 1887. Poecilanthrax efrenus ingår i släktet Poecilanthrax och familjen svävflugor. Inga underarter finns listade i Catalogue of Life.
Källor
Svävflugor
efrenus | swedish | 1.185792 |
Pony/format-FormatInt-.txt |
FormatInt¶
[Source]
type FormatInt is
(FormatDefault val | FormatUTF32 val | FormatBinary val | FormatBinaryBare val | FormatOctal val | FormatOctalBare val | FormatHex val | FormatHexBare val | FormatHexSmall val | FormatHexSmallBare val)
Type Alias For¶
(FormatDefault val | FormatUTF32 val | FormatBinary val | FormatBinaryBare val | FormatOctal val | FormatOctalBare val | FormatHex val | FormatHexBare val | FormatHexSmall val | FormatHexSmallBare val)
| pony | 199430 | https://nn.wikipedia.org/wiki/Bachkantater | Bachkantater | Bachkantater er eit oversyn som omfattar rundt 265 av dei om lag 300 kantatene som Bach skreiv. Av desse er berre 200 overleverte. Ved sida av pasjonane, oratoriene og Messe i h-moll høyrer kyrkjekantatene til Bach sine mest tungtvegande kyrkjemusikalske verk.
Lista kan sorterast etter BWV-nummer, tittel, plassering i kyrkjeåret, året Bach skreiv kantata og datoen for uroppføringa, om den er kjent. I andre kolonnar kan ein ordne songarar og instrumentalistar gruppevis. Dei arabiske tala gir talet på instrument i kvar kantate. Under merknad ser ein om det er snakk om noko anna enn ei kyrkjekantate; det kan ein òg sjå av fargekoden. I kolonnen nest lengst til høgre er lenkja til Bach Cantata Page (BCP), der ein kan finne fullstendige tekstar, oppbygging og annan detaljinformasjon. I siste kolonne finn ein lenkje til notemateriale i den gamle utgåva av Bach sine samla verk (Gesamtausgabe av Bach-Gesellschaft Leipzig) på IMSLP.
Forkortingar
Instrumenteringa er forkorta slik:
Merknader
Liste over kantater
Lista er bygd opp rundt Bach-Werke-Verzeichnis og omfattar alle kyrkjekantatene til Bach (den største delen av serien BWV 1–199) og verdslege kantater (som BWV 201, 203–209, 211–215), alle fragment (som BWV 80b, 216, 224, Anh. 224) og verk som ein tidlegare trudde var av Bach (som BWV 15, 53, 141, 160, 217–223), alle kantater der musikken er tapt (som BWV 36a, 66a, 70a, 80a, 120b), og alle verk som tidlegare blei regna som kantater, men som i røynda høyrer til ein annan musikksjanger (som BWV 11, 118).
Referansar
Litteratur
Alfred Dürr: Johann Sebastian Bach: Die Kantaten. 7. opplag. Bärenreiter, Kassel 1999, ISBN 3-7618-1476-3.
Werner Neumann: Handbuch der Kantaten Johann Sebastian Bachs. 1947, 5. opplag. Breitkopf & Härtel, Wiesbaden 1984, ISBN 3-7651-0054-4.
Martin Petzoldt: Bach-Kommentar. Theologisch-musikwissenschaftliche Kommentierung der geistlichen Vokalwerke Johann Sebastian Bachs.
Bind I: Die geistlichen Kantaten des 1. bis 27. Trinitatis-sonntages, Kassel/Stuttgart 2004.
Bind II: Die geistlichen Kantaten vom 1. Advent bis zum Trinitatisfest, Kassel/Stuttgart 2007.
Bind III under arbeid.
Hans-Joachim Schulze: Die Bach-Kantaten: Einführungen zu sämtlichen Kantaten Johann Sebastian Bachs. Leipzig: Evangelische Verlags-Anstalt; Stuttgart: Carus-Verlag 2006 (Edition Bach-Archiv Leipzig), ISBN 3-374-02390-8 (Evang. Verl.-Anst.), ISBN 3-89948-073-2 (Carus-Verl.).
Christoph Wolff/Ton Koopman: Die Welt der Bach-Kantaten. Verlag J.B. Metzler/Bärenreiter, Stuttgart u.a./Kassel 2006, ISBN 978-3-476-02127-4.
! | norwegian_nynorsk | 1.308404 |
Pony/cli-Help-.txt |
Help¶
[Source]
primitive val Help
Constructors¶
create¶
[Source]
new val create()
: Help val^
Returns¶
Help val^
Public Functions¶
general¶
[Source]
Creates a command help that can print a general program help message.
fun box general(
cs: CommandSpec box)
: CommandHelp box
Parameters¶
cs: CommandSpec box
Returns¶
CommandHelp box
for_command¶
[Source]
Creates a command help for a specific command that can print a detailed
help message.
fun box for_command(
cs: CommandSpec box,
argv: Array[String val] box)
: (CommandHelp box | SyntaxError val)
Parameters¶
cs: CommandSpec box
argv: Array[String val] box
Returns¶
(CommandHelp box | SyntaxError val)
eq¶
[Source]
fun box eq(
that: Help val)
: Bool val
Parameters¶
that: Help val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: Help val)
: Bool val
Parameters¶
that: Help val
Returns¶
Bool val
| pony | 451758 | https://no.wikipedia.org/wiki/Bankhvelv | Bankhvelv | Et bankhvelv er et forsterket brann- og tyverisikkert rom i en bank til oppbevaring av viktige papirer og verdisaker. Moderne bankhvelv inneholder typisk flere bankbokser, i tillegg til oppbevaringsplass for kassererens kontanter fra kasseapparatet, og andre verdifulle aktiva tilhørende banken eller kundene. Hvelv er også vanlige i andre bygninger hvor det oppbevares verdisaker, slik som postkontorer, store hoteller og visse statlige departementer.
Lignende tjenester
Postboks, en adresserbar og låsbar postkasse som leies fra et postkontor
Se også
Oppbevaringsskap, et lite oppbevaringsrom, av og til låsbart
Pengeskap (sikkerhetsskap, safe), et låsbart skap for å sikre verdifulle gjenstander
Våpenskap, oppbevaringsskap for skytevåpen
Bankvirksomhet
Sikkerhetsutstyr
Områdesikring | norwegian_bokmål | 1.373224 |
Pony/collections-Range-.txt |
Range[optional A: (Real[A] val & (I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val | F32 val | F64 val))]¶
[Source]
Produces [min, max) with a step of inc for any Number type.
// iterating with for-loop
for i in Range(0, 10) do
env.out.print(i.string())
end
// iterating over Range of U8 with while-loop
let range = Range[U8](5, 100, 5)
while range.has_next() do
try
handle_u8(range.next()?)
end
end
Supports min being smaller than max with negative inc
but only for signed integer types and floats:
var previous = 11
for left in Range[I64](10, -5, -1) do
if not (left < previous) then
error
end
previous = left
end
If inc is nonzero, but cannot produce progress towards max because of its sign, the Range is considered empty and will not produce any iterations. The Range is also empty if either min equals max, independent of the value of inc, or if inc is zero.
let empty_range1 = Range(0, 10, -1)
let empty_range2 = Range(0, 10, 0)
let empty_range3 = Range(10, 10)
empty_range1.is_empty() == true
empty_range2.is_empty() == true
empty_range3.is_empty() == true
Note that when using unsigned integers, a negative literal wraps around so while Range[ISize](0, 10, -1) is empty as above, Range[USize](0, 10, -1) produces a single value of min or [0] here.
When using Range with floating point types (F32 and F64) inc steps < 1.0 are possible. If any arguments contains NaN, the Range is considered empty. It is also empty if the lower bound min or the step inc are +Inf or -Inf. However, if only the upper bound max is +Inf or -Inf and the step parameter inc has the same sign, then the Range is considered infinite and will iterate indefinitely.
let p_inf: F64 = F64.max_value() + F64.max_value()
let n_inf: F64 = -p_inf
let nan: F64 = F64(0) / F64(0)
let infinite_range1 = Range[F64](0, p_inf, 1)
let infinite_range2 = Range[F64](0, n_inf, -1_000_000)
infinite_range1.is_infinite() == true
infinite_range2.is_infinite() == true
for i in Range[F64](0.5, 100, nan) do
// will not be executed as `inc` is nan
end
for i in Range[F64](0.5, 100, p_inf) do
// will not be executed as `inc` is +Inf
end
class ref Range[optional A: (Real[A] val & (I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val | F32 val |
F64 val))] is
Iterator[A] ref
Implements¶
Iterator[A] ref
Constructors¶
create¶
[Source]
new ref create(
min: A,
max: A,
inc: A = 1)
: Range[A] ref^
Parameters¶
min: A
max: A
inc: A = 1
Returns¶
Range[A] ref^
Public Functions¶
has_next¶
[Source]
fun box has_next()
: Bool val
Returns¶
Bool val
next¶
[Source]
fun ref next()
: A ?
Returns¶
A ?
rewind¶
[Source]
fun ref rewind()
: None val
Returns¶
None val
is_infinite¶
[Source]
fun box is_infinite()
: Bool val
Returns¶
Bool val
is_empty¶
[Source]
fun box is_empty()
: Bool val
Returns¶
Bool val
| pony | 8641195 | https://sv.wikipedia.org/wiki/Ludvig%20I%20av%20Flandern | Ludvig I av Flandern | Ludvig I av Flandern, född 1304, död 1346, var regerande greve av Flandern från 1322 till 1346.
Referenser
Födda 1304
Avlidna 1346
Män
Flanderns regenter | swedish | 1.449485 |
Pony/src-builtin-pointer-.txt |
pointer.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128struct Pointer[A]
"""
A Pointer[A] is a raw memory pointer. It has no descriptor and thus can't be
included in a union or intersection, or be a subtype of any interface. Most
functions on a Pointer[A] are private to maintain memory safety.
"""
new create() =>
"""
A null pointer.
"""
compile_intrinsic
new _alloc(len: USize) =>
"""
Space for len instances of A.
"""
compile_intrinsic
fun ref _realloc(len: USize, copy: USize): Pointer[A] =>
"""
Keep the contents, but reserve space for len instances of A.
"""
compile_intrinsic
fun tag _unsafe(): Pointer[A] ref =>
"""
Unsafe change in reference capability.
"""
compile_intrinsic
fun _convert[B](): this->Pointer[B] =>
"""
Convert from Pointer[A] to Pointer[B].
"""
compile_intrinsic
fun _apply(i: USize): this->A =>
"""
Retrieve index i.
"""
compile_intrinsic
fun ref _update(i: USize, value: A!): A^ =>
"""
Set index i and return the previous value.
"""
compile_intrinsic
fun _offset(n: USize): this->Pointer[A] =>
"""
Return a pointer to the n-th element.
"""
compile_intrinsic
fun tag offset(n: USize): Pointer[A] tag =>
"""
Return a tag pointer to the n-th element.
"""
_unsafe()._offset(n)
fun tag _element_size(): USize =>
"""
Return the size of a single element in an array of type A.
"""
compile_intrinsic
fun ref _insert(n: USize, len: USize): Pointer[A] =>
"""
Creates space for n new elements at the head, moving following elements.
The array length before this should be len, and the available space should
be at least n + len.
"""
compile_intrinsic
fun ref _delete(n: USize, len: USize): A^ =>
"""
Delete n elements from the head of pointer, compact remaining elements of
the underlying array. The array length before this should be n + len.
Returns the first deleted element.
"""
compile_intrinsic
fun _copy_to(that: Pointer[this->A!], n: USize): this->Pointer[A] =>
"""
Copy n elements from this to that.
"""
compile_intrinsic
fun tag usize(): USize =>
"""
Convert the pointer into an integer.
"""
compile_intrinsic
fun tag is_null(): Bool =>
"""
Return true for a null pointer, false for anything else.
"""
compile_intrinsic
fun tag eq(that: Pointer[A] tag): Bool =>
"""
Return true if this address is that address.
"""
compile_intrinsic
fun tag lt(that: Pointer[A] tag): Bool =>
"""
Return true if this address is less than that address.
"""
compile_intrinsic
fun tag ne(that: Pointer[A] tag): Bool => not eq(that)
fun tag le(that: Pointer[A] tag): Bool => lt(that) or eq(that)
fun tag ge(that: Pointer[A] tag): Bool => not lt(that)
fun tag gt(that: Pointer[A] tag): Bool => not le(that)
fun tag hash(): USize =>
"""
Returns a hash of the address.
"""
usize().hash()
fun tag hash64(): U64 =>
"""
Returns a 64-bit hash of the address.
"""
usize().hash64()
| pony | 1547419 | https://sv.wikipedia.org/wiki/Clojure | Clojure | Clojure är en dialekt inom Lisp-familjen av programmeringsspråk. Clojure skapades av Rich Hickey och släpptes i sin första version i slutet av 2009. Det är ett programmeringsspråk för allmän användning, som stödjer interaktiv utveckling och uppmuntrar en funktionell programmeringsstil. Clojure (liksom vissa andra programmeringsspråk) körs på Java Virtual Machine, Common Language Runtime och kan kompileras till Javascript.
Bakgrund
Enligt skaparen, Rich Hickey, är språket framtaget för att vara lättanvänt och ha god prestanda, snarare än att vara ett akademiskt projekt. Vidare ger Clojures API ett jämförelsevis enkelt förfarande för att inter-operera med existerande Java-bibliotek.
Kännetecken
Clojure är ett språk med fokus på funktionell programmering och samverkande ("concurrent" på engelska) programmering. På grund av denna inriktning stödjer Clojure följande funktioner:
STM (Software Transactional Memory) med inbyggda makron för att genomföra atomiska transaktioner på gemensamma data
Persistenta datastrukturer
Funktioner av första klass (funktioner är värden)
Syntax
Clojures syntax byggs på S-uttryck, något som är typiskt för ett Lisp-språk. Clojure är en Lisp-1, vilket innebär att funktioner och andra värden delar på en namnrymd. Språket kan inte kodas om till andra Lisp-dialekter eftersom det inte är kompatibelt.
Det som i huvudsak gör Clojure inkompatibelt med andra dialekter är att Clojure använder specifika teckenpar för att ange olika sorters datastrukturer.
I Clojure används [] för att ange vektorer, {} för att ange associativa vektorer och #{} för att ange associativa vektorer med unika värden.
Exempel
Hello world:
(println "Hello, world!")
Nedan definieras en funktion som tar en parameter (x) som anges som en vektor med ett element. Funktionen anropar multiplikationsfunktionen * med argumenten x, x. I Clojure, som med andra Lisp-dialekter, returneras det värde som den sist anropade funktionen returnerar automatiskt:
(defn square [x]
(* x x))
Genom att använda Javas Swing bibliotek är det möjligt att rita grafiska gränssnitt (ytterligare ett Hello World-exempel):
(javax.swing.JOptionPane/showMessageDialog nil "Hello World" )
Nedan ges exempel på en trådsäker generator av unika serienummer:
(let [i (atom 0)]
(defn generate-unique-id
"Returns a distinct numeric ID for each call."
[]
(swap! i inc)))
En anonym underklass av java.io.Writer som inte skriver till någonting, och ett makro som använder detta för att tysta alla 'prints' inuti det:
(def bit-bucket-writer
(proxy [java.io.Writer] []
(write [buf] nil)
(close [] nil)
(flush [] nil)))
(defmacro noprint
"Evaluates the given expressions with all printing to *out* silenced."
[& forms]
`(binding [*out* bit-bucket-writer]
~@forms))
(noprint
(println "Hello, nobody!"))
Tio trådar manipulerar en gemensam datastruktur, vilken består av 100 vektorer, där varje vektor använder 10 (initialt sekventiella) unika tal. Varje tråd väljer repetitivt två slumpvisa positioner i två slumpvisa vektorer och byter plats på dem.
Alla ändringar till vektorerna händer i transaktioner genom att använda clojures software transactional memory system. Tack vare denna transaktionskontroll tappas inget data bort trots att man manipulerar vektorerna från flera trådar parallellt 100 000 gånger i exemplet.
(defn run [nvecs nitems nthreads niters]
(let [vec-refs (vec (map (comp ref vec)
(partition nitems (range (* nvecs nitems)))))
swap #(let [v1 (rand-int nvecs)
v2 (rand-int nvecs)
i1 (rand-int nitems)
i2 (rand-int nitems)]
(dosync
(let [temp (nth @(vec-refs v1) i1)]
(alter (vec-refs v1) assoc i1 (nth @(vec-refs v2) i2))
(alter (vec-refs v2) assoc i2 temp))))
report #(do
(prn (map deref vec-refs))
(println "Distinct:"
(count (distinct (apply concat (map deref vec-refs))))))]
(report)
(dorun (apply pcalls (repeat nthreads #(dotimes [_ niters] (swap)))))
(report)))
(run 100 10 10 100000)
Utfall av föregående exempel:
([0 1 2 3 4 5 6 7 8 9] [10 11 12 13 14 15 16 17 18 19] ...
[990 991 992 993 994 995 996 997 998 999])
Distinct: 1000
([382 318 466 963 619 22 21 273 45 596] [808 639 804 471 394 904 952 75 289 778] ...
[484 216 622 139 651 592 379 228 242 355])
Distinct: 1000
Lisp
Programspråk | swedish | 0.721636 |
Pony/collections--index-.txt |
Collections package¶
The Collections package provides a variety of collection classes,
including map, set, range, heap, ring buffer, list, and flags.
Map - Hashmap by strutural equality (use MapIs for identity equality).
Set - A set built on top of Map using structural equility (use SetIs for identity equality).
Range - Iterate over a range of numbers with optional step size.
BinaryHeap - A priority queue implemented as a binary heap -- use a BinaryHeapPriority parameter to determine priority.
RingBuffer - A ring buffer with fixed size.
List - A doubly linked list.
Flags - A set of single bit flags (size determined upon creation).
Public Types¶
class BinaryHeap
type BinaryHeapPriority
interface Flag
class Flags
primitive HashByteSeq
primitive HashEq
primitive HashEq64
interface HashFunction
interface HashFunction64
primitive HashIs
class HashMap
class HashSet
interface Hashable
interface Hashable64
class List
class ListNode
class ListNodes
class ListValues
type Map
type MapIs
class MapKeys
class MapPairs
class MapValues
type MaxHeap
primitive MaxHeapPriority
type MinHeap
primitive MinHeapPriority
class Range
class Reverse
class RingBuffer
type Set
type SetIs
class SetValues
primitive Sort
| pony | 4237561 | https://sv.wikipedia.org/wiki/Polygonatum%20hybridum | Polygonatum hybridum | Polygonatum hybridum är en sparrisväxtart som beskrevs av Christian Georg Brügger. Polygonatum hybridum ingår i släktet ramsar, och familjen sparrisväxter. Inga underarter finns listade i Catalogue of Life.
Källor
Externa länkar
Ramsar
hybridum | swedish | 1.206199 |
Pony/collections-HashIs-.txt |
HashIs[A: A]¶
[Source]
primitive val HashIs[A: A] is
HashFunction[A] val,
HashFunction64[A] val
Implements¶
HashFunction[A] val
HashFunction64[A] val
Constructors¶
create¶
[Source]
new val create()
: HashIs[A] val^
Returns¶
HashIs[A] val^
Public Functions¶
hash¶
[Source]
Hash the identity rather than the contents.
fun box hash(
x: box->A!)
: USize val
Parameters¶
x: box->A!
Returns¶
USize val
hash64¶
[Source]
Hash the identity rather than the contents.
fun box hash64(
x: box->A!)
: U64 val
Parameters¶
x: box->A!
Returns¶
U64 val
eq¶
[Source]
Determine equality by identity rather than structurally.
fun box eq(
x: box->A!,
y: box->A!)
: Bool val
Parameters¶
x: box->A!
y: box->A!
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: HashIs[A] val)
: Bool val
Parameters¶
that: HashIs[A] val
Returns¶
Bool val
| pony | 1974416 | https://sv.wikipedia.org/wiki/Ainigmaptilon%20haswelli | Ainigmaptilon haswelli | Ainigmaptilon haswelli är en korallart som beskrevs av Dean 1926. Ainigmaptilon haswelli ingår i släktet Ainigmaptilon och familjen Primnoidae.
Artens utbredningsområde är Södra Ishavet. Inga underarter finns listade i Catalogue of Life.
Källor
Koralldjur
haswelli | swedish | 1.292571 |
Pony/pony_test--index-.txt |
PonyTest package¶
The PonyTest package provides a unit testing framework. It is designed to be as
simple as possible to use, both for the unit test writer and the user running
the tests.
To help simplify test writing and distribution this package depends on as few
other packages as possible. Currently the required packages are:
builtin
time
collections
Each unit test is a class, with a single test function. By default all tests
run concurrently.
Each test run is provided with a helper object. This provides logging and
assertion functions. By default log messages are only shown for tests that
fail.
When any assertion function fails the test is counted as a fail. However, tests
can also indicate failure by raising an error in the test function.
Example program¶
To use PonyTest simply write a class for each test and a TestList type that
tells the PonyTest object about the tests. Typically the TestList will be Main
for the package.
The following is a complete program with 2 trivial tests.
use "pony_test"
actor Main is TestList
new create(env: Env) =>
PonyTest(env, this)
new make() =>
None
fun tag tests(test: PonyTest) =>
test(_TestAdd)
test(_TestSub)
class iso _TestAdd is UnitTest
fun name():String => "addition"
fun apply(h: TestHelper) =>
h.assert_eq[U32](4, 2 + 2)
class iso _TestSub is UnitTest
fun name():String => "subtraction"
fun apply(h: TestHelper) =>
h.assert_eq[U32](2, 4 - 2)
The make() constructor is not needed for this example. However, it allows for
easy aggregation of tests (see below) so it is recommended that all test Mains
provide it.
Main.create() is called only for program invocations on the current package.
Main.make() is called during aggregation. If so desired extra code can be added
to either of these constructors to perform additional tasks.
Test names¶
Tests are identified by names, which are used when printing test results and on
the command line to select which tests to run. These names are independent of
the names of the test classes in the Pony source code.
Arbitrary strings can be used for these names, but for large projects it is
strongly recommended to use a hierarchical naming scheme to make it easier to
select groups of tests.
You can skip any tests whose names start with a given string by using the
--exclude=[prefix] command line option.
You can run only tests whose names start with a given string by using the
--only=[prefix] command line option.
Aggregation¶
Often it is desirable to run a collection of unit tests from multiple different
source files. For example, if several packages within a bundle each have their
own unit tests it may be useful to run all tests for the bundle together.
This can be achieved by writing an aggregate test list class, which calls the
list function for each package. The following is an example that aggregates the
tests from packages foo and bar.
use "pony_test"
use bar = "bar"
use foo = "foo"
actor Main is TestList
new create(env: Env) =>
PonyTest(env, this)
new make() =>
None
fun tag tests(test: PonyTest) =>
bar.Main.make().tests(test)
foo.Main.make().tests(test)
Aggregate test classes may themselves be aggregated. Every test list class may
contain any combination of its own tests and aggregated lists.
Long tests¶
Simple tests run within a single function. When that function exits, either
returning or raising an error, the test is complete. This is not viable for
tests that need to use actors.
Long tests allow for delayed completion. Any test can call long_test() on its
TestHelper to indicate that it needs to keep running. When the test is finally
complete it calls complete() on its TestHelper.
The complete() function takes a Bool parameter to specify whether the test was
a success. If any asserts fail then the test will be considered a failure
regardless of the value of this parameter. However, complete() must still be
called.
Since failing tests may hang, a timeout must be specified for each long test.
When the test function exits a timer is started with the specified timeout. If
this timer fires before complete() is called the test is marked as a failure
and the timeout is reported.
On a timeout the timed_out() function is called on the unit test object. This
should perform whatever test specific tidy up is required to allow the program
to exit. There is no need to call complete() if a timeout occurs, although it
is not an error to do so.
Note that the timeout is only relevant when a test hangs and would otherwise
prevent the test program from completing. Setting a very long timeout on tests
that should not be able to hang is perfectly acceptable and will not make the
test take any longer if successful.
Timeouts should not be used as the standard method of detecting if a test has
failed.
Exclusion groups¶
By default all tests are run concurrently. This may be a problem for some
tests, eg if they manipulate an external file or use a system resource. To fix
this issue any number of tests may be put into an exclusion group.
No tests that are in the same exclusion group will be run concurrently.
Exclusion groups are identified by name, arbitrary strings may be used.
Multiple exclusion groups may be used and tests in different groups may run
concurrently. Tests that do not specify an exclusion group may be run
concurrently with any other tests.
The command line option "--sequential" prevents any tests from running
concurrently, regardless of exclusion groups. This is intended for debugging
rather than standard use.
Labels¶
Test can have label. Labels are used to filter which tests are run, by setting
command line argument --label=[some custom label]. It can be used to separate
unit tests from integration tests.
By default label is empty. You can set it up by overriding label(): String
method in unit test.
use "pony_test"
class iso _I8AddTest is UnitTest
fun name(): String => "_I8AddTest"
fun label(): String => "simple"
fun apply(h: TestHelper) =>
h.assert_eq[I8](1, 1)
Setting up and tearing down a test environment¶
Set Up¶
Any kind of fixture or environment necessary for executing a UnitTest
can be set up either in the tests constructor or in a function called set_up().
set_up() is called before the test is executed. It is partial,
if it errors, the test is not executed but reported as failing during set up.
The test's TestHelper is handed to set_up()
in order to log messages or access the tests Env via TestHelper.env.
Tear Down¶
Each unit test object may define a tear_down() function. This is called after
the test has finished to allow tearing down of any complex environment that had
to be set up for the test.
The tear_down() function is called for each test regardless of whether it
passed or failed. If a test times out tear_down() will be called after
timed_out() returns.
When a test is in an exclusion group, the tear_down() call is considered part
of the tests run. The next test in the exclusion group will not start until
after tear_down() returns on the current test.
The test's TestHelper is handed to tear_down() and it is permitted to log
messages and call assert functions during tear down.
Example¶
The following example creates a temporary directory in the set_up() function
and removes it in the tear_down() function, thus
simplifying the test function itself:
use "pony_test"
use "files"
class iso TempDirTest
var tmp_dir: (FilePath | None) = None
fun name(): String => "temp-dir"
fun ref set_up(h: TestHelper)? =>
tmp_dir = FilePath.mkdtemp(FileAuth(h.env.root), "temp-dir")?
fun ref tear_down(h: TestHelper) =>
try
(tmp_dir as FilePath).remove()
end
fun apply(h: TestHelper)? =>
let dir = tmp_dir as FilePath
// do something inside the temporary directory
Public Types¶
interface ITest
actor PonyTest
class TestHelper
trait TestList
trait UnitTest
| pony | 2651098 | https://sv.wikipedia.org/wiki/Clastoptera%20testacea | Clastoptera testacea | Clastoptera testacea är en insektsart som beskrevs av Fitch 1851. Clastoptera testacea ingår i släktet Clastoptera och familjen Clastopteridae. Inga underarter finns listade i Catalogue of Life.
Källor
Halvvingar
testacea | swedish | 1.328763 |
Pony/src-collections-heap-.txt |
heap.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144type MinHeap[A: Comparable[A] #read] is BinaryHeap[A, MinHeapPriority[A]]
type MaxHeap[A: Comparable[A] #read] is BinaryHeap[A, MaxHeapPriority[A]]
class BinaryHeap[A: Comparable[A] #read, P: BinaryHeapPriority[A]]
"""
A priority queue implemented as a binary heap. The `BinaryHeapPriority` type
parameter determines whether this is max-heap or a min-heap.
"""
embed _data: Array[A]
new create(len: USize) =>
"""
Create an empty heap with space for `len` elements.
"""
_data = Array[A](len)
fun ref clear() =>
"""
Remove all elements from the heap.
"""
_data.clear()
fun size(): USize =>
"""
Return the number of elements in the heap.
"""
_data.size()
fun peek(): this->A ? =>
"""
Return the highest priority item in the heap. For max-heaps, the greatest
item will be returned. For min-heaps, the smallest item will be returned.
"""
_data(0)?
fun ref push(value: A) =>
"""
Push an item into the heap.
The time complexity of this operation is O(log(n)) with respect to the size
of the heap.
"""
_data.push(value)
_sift_up(size() - 1)
fun ref pop(): A^ ? =>
"""
Remove the highest priority value from the heap and return it. For
max-heaps, the greatest item will be returned. For min-heaps, the smallest
item will be returned.
The time complexity of this operation is O(log(n)) with respect to the size
of the heap.
"""
let n = size() - 1
_data.swap_elements(0, n)?
_sift_down(0, n)
_data.pop()?
fun ref append(
seq: (ReadSeq[A] & ReadElement[A^]),
offset: USize = 0,
len: USize = -1)
=>
"""
Append len elements from a sequence, starting from the given offset.
"""
_data.append(seq, offset, len)
_make_heap()
fun ref concat(iter: Iterator[A^], offset: USize = 0, len: USize = -1) =>
"""
Add len iterated elements, starting from the given offset.
"""
_data.concat(iter, offset, len)
_make_heap()
fun values(): ArrayValues[A, this->Array[A]]^ =>
"""
Return an iterator for the elements in the heap. The order of elements is
arbitrary.
"""
_data.values()
fun ref _make_heap() =>
let n = size()
if n < 2 then return end
var i = (n / 2)
while (i = i - 1) > 0 do
_sift_down(i, n)
end
fun ref _sift_up(n: USize) =>
var idx = n
try
while true do
let parent_idx = (idx - 1) / 2
if (parent_idx == idx) or not P(_data(idx)?, _data(parent_idx)?) then
break
end
_data.swap_elements(parent_idx, idx)?
idx = parent_idx
end
end
fun ref _sift_down(start: USize, n: USize): Bool =>
var idx = start
try
while true do
var left = (2 * idx) + 1
if (left >= n) or (left < 0) then
break
end
let right = left + 1
if (right < n) and P(_data(right)?, _data(left)?) then
left = right
end
if not P(_data(left)?, _data(idx)?) then
break
end
_data.swap_elements(idx, left)?
idx = left
end
end
idx > start
fun _apply(i: USize): this->A ? =>
_data(i)?
type BinaryHeapPriority[A: Comparable[A] #read] is
( _BinaryHeapPriority[A]
& (MinHeapPriority[A] | MaxHeapPriority[A]))
interface val _BinaryHeapPriority[A: Comparable[A] #read]
new val create()
fun apply(x: A, y: A): Bool
primitive MinHeapPriority[A: Comparable[A] #read] is _BinaryHeapPriority[A]
fun apply(x: A, y: A): Bool =>
x < y
primitive MaxHeapPriority [A: Comparable[A] #read] is _BinaryHeapPriority[A]
fun apply(x: A, y: A): Bool =>
x > y
| pony | 4228988 | https://sv.wikipedia.org/wiki/Agave%20subsimplex | Agave subsimplex | Agave subsimplex är en sparrisväxtart som beskrevs av William Trelease. Agave subsimplex ingår i släktet Agave och familjen sparrisväxter. Inga underarter finns listade i Catalogue of Life.
Källor
Sparrisväxter
subsimplex | swedish | 1.107628 |
Pony/process-CapError-.txt |
CapError¶
[Source]
primitive val CapError
Constructors¶
create¶
[Source]
new val create()
: CapError val^
Returns¶
CapError val^
Public Functions¶
string¶
[Source]
fun box string()
: String iso^
Returns¶
String iso^
eq¶
[Source]
fun box eq(
that: CapError val)
: Bool val
Parameters¶
that: CapError val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: CapError val)
: Bool val
Parameters¶
that: CapError val
Returns¶
Bool val
| pony | 2821125 | https://sv.wikipedia.org/wiki/Ebepius%20ochrascens | Ebepius ochrascens | Ebepius ochrascens är en fjärilsart som beskrevs av Sheffield Airey Neave 1904. Ebepius ochrascens ingår i släktet Ebepius och familjen juvelvingar. Inga underarter finns listade i Catalogue of Life.
Källor
Juvelvingar
ochrascens | swedish | 1.058754 |
Pony/src-promises-fulfill-.txt |
fulfill.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28primitive _Pending
primitive _Reject
interface iso Fulfill[A: Any #share, B: Any #share]
"""
A function from A to B that is called when a promise is fulfilled.
"""
fun ref apply(value: A): B ?
interface iso Reject[A: Any #share]
"""
A function on A that is called when a promise is rejected.
"""
fun ref apply(): A ?
class iso FulfillIdentity[A: Any #share]
"""
An identity function for fulfilling promises.
"""
fun ref apply(value: A): A =>
consume value
class iso RejectAlways[A: Any #share]
"""
A reject that always raises an error.
"""
fun ref apply(): A ? =>
error
| pony | 1748009 | https://no.wikipedia.org/wiki/React%20%28webrammeverk%29 | React (webrammeverk) | React (også kjent som React.js og ReactJS) er et JavaScript-bibliotek for å lage og bygge brukergrensesnitt. Det vedlikeholdes av Meta (tidligere Facebook) og et fellesskap av ulike utviklere og selskaper.
React brukes gjerne som et utgangspunkt i utviklingen av enkeltside- (engelsk single-page) eller mobilapplikasjoner. Rammeverket er optimalisert for raskt å hente ut skiftende data som må registreres. Henting av data er imidlertid bare begynnelsen på det som skjer på en nettside, og det er grunnen til at komplekse React-applikasjoner vanligvis krever ekstra biblioteker for tilstandsstyring, ruting og interaksjon med et API. Redux, React Router og Axios er eksempler på slike biblioteker.
Historie
React ble i utgangspunktet utviklet i 2011 av Jordan Walke, en programvareingeniør ved Facebook, først og fremst ved utviklingen av Facebooks Newsfeed-produkt. Senere ble det videreført og tatt i bruk i 2012 i bildedelingstjenesten Instagram. I mai 2013 kunngjorde Facebook at de ønsket å videreføre React i framtiden som et Open Source-Prosjekt. I oktober 2014 ble Reacts programvarelisens endret fra Apache-lisensen til BSD-lisensen som en ytterligere patentlisens, som forbeholder Facebook retten til å trekke tilbake lisensen ved patentstridigheter. Denne ukonvensjonelle klausulen førte til en kontroversiell diskusjon. En omformulering av denne patentklausulen i april 2015 førte ikke til en slutt på konfliktene. I juli 2017 offentliggjorde Apace Software Foundation at de ikke tillater at apache-prosjekter kan ha denne tilleggslisensen. Kontra den opprinnelige informasjonen og uten ønske om å gå tilbake fra klausulen, offentliggjorde Facebook i september 2017 React versjon 16.0.0. under lisensen MIT.
Grunnleggende bruk
Følgende er et rudimentært eksempel på React-bruk i HTML med JSX og JavaScript.
<div id="myReactApp"></div>
<script type="text/babel">
class Greeter extends React.Component {
render() {
return <h1>{this.props.greeting}</h1>
}
}
ReactDOM.render(<Greeter greeting="Hello World!" />, document.getElementById('myReactApp'));
</script>
Greeter-klassen er en React-komponent som godtar en egenskap greeting. ReactDOM.render-metoden skaper en forekomst av Greeter-komponenten, setter greeting-forekomsten til 'Hello World' og setter inn den gjengitte komponenten som et barnelement i DOM-elementet med ID myReactApp.
Når det vises i en nettleser, blir resultatet
<div id="myReactApp">
<h1>Hello World!</h1>
</div>
Referanser
Eksterne lenker
React eksempel
Programvare fra 2015
Webrammeverk
Facebook | norwegian_bokmål | 1.048871 |
Pony/pony_check-WeightedGenerator-.txt |
WeightedGenerator[T: T]¶
[Source]
A generator with an associated weight, used in Generators.frequency.
type WeightedGenerator[T: T] is
(USize val , Generator[T] box)
Type Alias For¶
(USize val , Generator[T] box)
| pony | 1690839 | https://no.wikipedia.org/wiki/TM3 | TM3 | TM3 kan vise til:
Kubikkterameter (Tm³), måleenhet for volum
Tesla Model 3, bilmodell | norwegian_bokmål | 1.050237 |
Pony/pony_check-ASCIIDigits-.txt |
ASCIIDigits¶
[Source]
primitive val ASCIIDigits
Constructors¶
create¶
[Source]
new val create()
: ASCIIDigits val^
Returns¶
ASCIIDigits val^
Public Functions¶
apply¶
[Source]
fun box apply()
: String val
Returns¶
String val
eq¶
[Source]
fun box eq(
that: ASCIIDigits val)
: Bool val
Parameters¶
that: ASCIIDigits val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: ASCIIDigits val)
: Bool val
Parameters¶
that: ASCIIDigits val
Returns¶
Bool val
| pony | 53278 | https://da.wikipedia.org/wiki/Base64 | Base64 | Base64 er et begreb fra Datalogi, som anvendes til at formidle binær 8-bit (= 1 byte) formede data gennem en e-mail. Alle postprogrammer inkl. internettets første kan formidle kodningsformen. Kodningsformen er designet så kodningen uden problemer kan formidles af 7-bit systemer smtp oprindeligt kun kunne håndtere.
Base64 bliver anvendt i internetstandarden MIME (Multipurpose Internet Mail Extensions) og anvendes til at indlejre et eller flere bilag (eng. attachment) i selve mailen.
Til kodningen anvendes tegnene A-Z, a-z, 0-9, + og / og evt. et eller to = som fyld i slutningen af kodningen. Da disse tegn også repræsenteres i EBCDIC (dog med andre kodepositioner), kan bilag også formidles via EBCDIC.
Som det ses skal der anvendes 4 6 bit blokke for hver 3 byte. Hver 6 bit blok omsættes til et Base64-tegn via følgende tabel:
beskriver kodningen.
Eksempel
Hätten Hüte ein ß im Namen, wären sie möglicherweise keine Hüte mehr,
sondern Hüße.
Her ses ovenstående 2 linjer kodet som Base64 i vist i ASCII:
SMOkdHRlbiBIw7x0ZSBlaW4gw58gaW0gTmFtZW4sIHfDpHJlbiBzaWUgbcO2Z2xpY2hlcndlaXNl
IGtlaW5lIEjDvHRlIG1laHIsDQpzb25kZXJuIEjDvMOfZS4NCg==
Som det ses er Base64 kodet tekst ikke læsbart, hvilket quoted-printable-kodningen delvis er.
Se også
quoted-printable, UUencode, Base16, Base32, Base85
Eksterne henvisninger
http://www.faqs.org/rfcs/rfc1421.html
http://www.faqs.org/rfcs/rfc1521.html
http://www.faqs.org/rfcs/rfc3548.html
Binær-til-tekst kodningsformater | danish | 0.957399 |
Pony/builtin-Signed-.txt |
Signed¶
[Source]
type Signed is
(I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val)
Type Alias For¶
(I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val)
| pony | 30067 | https://no.wikipedia.org/wiki/Opel%20Vectra | Opel Vectra | Opel Vectra er en bilmodell fra Opel produsert fra 1988. Den overtok etter Ascona og ble levert som sedan, kombi og stasjonsvogn.
Opel Vectra var en bil på størrelse med Nissan Primera/Mitsubishi Galant. Men etter Vectras oppgradering i 2002, vokste bilen, og ble nærmest en overtaker til Omega størrelsesmessig. Modellen var plassert i D-segmentet, klassen for mellomstore biler. Forgjengeren, Ascona, tilhørte segment C.
Vectra er en bil som finnes i mange utstyrsvarianter. Den finnes også i OPC versjon (Opel Performance Center). Det vil si en versjon av bilen som har mer utstyr og større fokus på sportslighet enn de andre modellene.
I mai 2008 informerte Opel om at Vectra ville gå ut av produksjon snarlig. Ingen spesiell årsak skal ha blitt nevnt, annet enn at modellen ville få en oppfølger, Opel Insignia.
Vectra A
Vectra A kom høsten 1988 som 1989-modell. Den erstattet Ascona. Designet var vesentlig modernisert. Vectra har frontmotor og framhjulsdrift, men ble også levert med firehjulstrekk. Vectra A kunne også leveres med kombinasjonen firehjulsdrift og turboladet bensinmotor.
Bensin
1.4 S: Forgasser 4 syl 8V (14NV), 1 389 cm³, 55 kW (75 hk), 108 Nm, 1988-1992
1.6 S: Forgasser 4 syl 8V (16SV), 1 598 cm³, 60 kW (82 hk), 130 Nm, 1988-1993
1.6 i: Innsprøyting 4 syl 8V (X16SZ), 1 598 cm³, 52 kW (71 hk), 128 Nm, 1993-1995
1.6 i: Innsprøyting 4 syl 8V (C16NZ(2) / E16NZ), 1 598 cm³, 55 kW (75 hk), 125 Nm, 1988-1993
1.6 i: Innsprøyting 4 syl 8V (16LZ2), 1 597 cm³, 55 kW (75 hk), 120 Nm, 1993-1995
1.8 S: Forgasser 4 syl 8V (18SV), 1 796 cm³, 66 kW (90 hk), 148 Nm, 1988-1990
1.8 S: Forgasser 4 syl 8V (E18NVR), 1 796 cm³, 65 kW (88 hk), 143 Nm, 1988-1989
1.8 i: Innsprøyting 4 syl 8V (C18NZ), 1 796 cm³, 66 kW (90 hk), 145 Nm, 1990-1995
2.0 i: Innsprøyting 4 syl 8V (C20NEF), 1 998 cm³, 74 kW (101 hk), 158 Nm, 1988-1989
2.0 i: Innsprøyting 4 syl 8V (C20NE), 1 998 cm³, 85 kW (116 hk), 170 Nm, 1988-1995
2.0 i: Innsprøyting 4 syl 8V (20NE), 1 998 cm³, 85 kW (116 hk), 170 Nm, 1988-1990
2.0 i: Innsprøyting 4 syl 8V (20SEH), 1 998 cm³, 95 kW (129 hk), 180 Nm, 1988-1992
2.0 i: Innsprøyting 4 syl 16V ((C)20XE), 1 998 cm³, 110 kW (150 hk), 196 Nm, 1988-1994
2.0 i: Innsprøyting 4 syl 16V (X20XEV), 1 998 cm³, 100 kW (136 hk), 185 Nm, 1994-1995
2.0 i Turbo: Innsprøyting 4 syl 16V (C20LET), 1 998 cm³, 150 kW (204 hk), 280 Nm, 1994-1995
2.5 i V6: Innsprøyting 6 syl 24V (C25XE), 2 498 cm³, 125 kW (170 hk), 227 Nm, 1993-1995
Diesel
1.7 D: Diesel 4 syl 8V (17D), 1 700 cm³, 42 kW (57 hk), 105 Nm, 1988-1992
1.7 D: Diesel 4 syl 8V (17DR), 1 700 cm³, 44 kW (60 hk), 105 Nm, 1992-1995
1.7 TD: Turbodiesel 4 syl 8V (TC4EE1), 1 686 cm³, 60 kW (82 hk), 168 Nm, 1990-1995
Vectra B
Introdusert høsten 1995 som arvtaker til Vectra A og produsert frem til 2002, da Vectra C ble introdusert.
Modellspekteret spente da ifra GL via CD til CDX. GL ble levert med 1,6 L 100hk, 1,8 l 115hk, 2,0 l 136hk motor og 1,7 l TD på 82 hk mens CD kunne leveres med 1,8 l 115 hk, 2,0 l 136 hk eller 2,0 l TD på 100 hk. CDX var toppmodellen og ble bare levert med 2,0 l 136 hk, 2,5/2,6 l V6 170 hk, 2,2 l 147 hk eller 2,2 l DTI 125/120 hk. Fikk i 1999 facelift med samme motoralternativer. I 2001 ble ustyrsgradene endret til «Comfort», «Sport» og «Elegance».
Det fantes også en spesial-modell som ble kalt i500 som var levert med en 2,6 l V6 med 195 hk.
Vectra C
Introdusert høsten 2002. Vesentlig endret i forhold til Vectra A og B, ikke minst teknisk sett.
Kom først kun som personbil våren 2002, med 1,8 bensin, 2,2 bensin, 2,0 diesel eller 2,2 diesel med mauell girkasse eller automat med step. Ustyrsnivåene het da «Club», «Comfort» og «Elegance». Høsten 2002 kom det som da var tidenes raskeste, serieproduserte Opel. Dette var Vectra GTS 3,2. Denne var en vesentlig mer sportslig utgave med coupéform og ekstra styling. Denne hadde i tillegg et sportslig utviklet utgave av det meget avanserte IDS understellet. Denne kom senere i tillegg til 3,2 V6 med 1,8, 2,2, 2,2 Diesel, 3,0 V6 diesel og 2,0 turbo bensin. Høsten 2004 kom stasjonsvognsmodellen, med de samme motoralternativer som GTS og sedan. I overgangen 2004/2005 var endringene minimale, men man kunne nå velge fritt imellom alle motoralternativer og ustyrsalternativer på alle karroseriformer, f.eks. GTS som stasjonsvogn. I tillegg kom det en ny Premiummodell kalt «Cosmo».
Våren 2006 kom den i "faceliftet" utgave, 3,2 literen ble faset ut til fordel for en 2,8 V6 med turbo. I tillegg kom OPC – Opel Performance Center med egne preformancemodeller av Vectra med en tunet 2,8 liter på 280 hk og ekstra styling/Recarointeriør og den karakteristiske blåfargen. Det ble også dette året mulighet for å velge en "OPC-line" pakke til en vanlig Vectra, med den ekstra OPC-stylingen på f.eks. en 1,8 stasjonsvogn.
Kjente feil og problemer
På 1,8- og 2,0-liters bensin motorene, er det svært viktig å følge opp intervallene på registerreim. Registerreima skal byttes etter 60 000 km eller hvert fjerde år (det som kommer først). Hvis dette ikke gjøres, er det stor sannsynlighet for at reima ryker – med havari som følge. Andre vanlige motorfeil er oljelekkasje fra toppdekselpakning. Dieselmotorene er det derimot lite feil med. På bremsene er feil på bremseskiver bak velkjent, og på litt eldre biler kan også bremserørene være rustne. Slitte foringer i bakstilling er en annen vanlig feil. Foran er det kuler og lenkarmer i forstilling som er den vanligste feilen. Når det gjelder rust, er hjulbuene bak ganske utsatt.
Referanser
Eksterne lenker
Vectra
Bilmodeller introdusert i 1988 | norwegian_bokmål | 1.416933 |
Pony/src-format-align-.txt |
align.pony
1
2
3
4
5
6
7
8primitive AlignLeft
primitive AlignRight
primitive AlignCenter
type Align is
( AlignLeft
| AlignRight
| AlignCenter )
| pony | 2045244 | https://no.wikipedia.org/wiki/Aye%20Aye%20Aung | Aye Aye Aung | Aye Aye Aung kan være:
Aye Aye Aung (judoka)
Aye Aye Aung (vektløfter)
Aye Aye Aung (friidrettsutøver) | norwegian_bokmål | 0.846861 |
Pony/pony_check-Generators-.txt |
Generators¶
[Source]
Convenience combinators and factories for common types and kind of Generators.
primitive val Generators
Constructors¶
create¶
[Source]
new val create()
: Generators val^
Returns¶
Generators val^
Public Functions¶
unit[T: T]¶
[Source]
Generate a reference to the same value over and over again.
This reference will be of type box->T and not just T
as this generator will need to keep a reference to the given value.
fun box unit[T: T](
t: T,
do_shrink: Bool val = false)
: Generator[box->T] box
Parameters¶
t: T
do_shrink: Bool val = false
Returns¶
Generator[box->T] box
none[T: None val]¶
[Source]
fun box none[T: None val]()
: Generator[(T | None val)] box
Returns¶
Generator[(T | None val)] box
repeatedly[T: T]¶
[Source]
Generate values by calling the lambda f repeatedly,
once for every invocation of generate.
f needs to return an ephemeral type T^, that means
in most cases it needs to consume its returned value.
Otherwise we would end up with
an alias for T which is T!.
(e.g. String iso would be returned as String iso!,
which aliases as a String tag).
Example:
Generators.repeatedly[Writer]({(): Writer^ =>
let writer = Writer.>write("consume me, please")
consume writer
})
fun box repeatedly[T: T](
f: {(): T^ ?}[T] box)
: Generator[T] box
Parameters¶
f: {(): T^ ?}[T] box
Returns¶
Generator[T] box
seq_of[T: T, S: Seq[T] ref]¶
[Source]
Create a Seq from the values of the given Generator with an optional
minimum and maximum size.
Defaults are 0 and 100, respectively.
fun box seq_of[T: T, S: Seq[T] ref](
gen: Generator[T] box,
min: USize val = 0,
max: USize val = 100)
: Generator[S] box
Parameters¶
gen: Generator[T] box
min: USize val = 0
max: USize val = 100
Returns¶
Generator[S] box
iso_seq_of[T: Any #send, S: Seq[T] iso]¶
[Source]
Generate a Seq[T] where T must be sendable (i.e. it must have a
reference capability of either tag, val, or iso).
The constraint of the elements being sendable stems from the fact that
there is no other way to populate the iso seq if the elements might be
non-sendable (i.e. ref), as then the seq would leak references via
its elements.
fun box iso_seq_of[T: Any #send, S: Seq[T] iso](
gen: Generator[T] box,
min: USize val = 0,
max: USize val = 100)
: Generator[S] box
Parameters¶
gen: Generator[T] box
min: USize val = 0
max: USize val = 100
Returns¶
Generator[S] box
array_of[T: T]¶
[Source]
fun box array_of[T: T](
gen: Generator[T] box,
min: USize val = 0,
max: USize val = 100)
: Generator[Array[T] ref] box
Parameters¶
gen: Generator[T] box
min: USize val = 0
max: USize val = 100
Returns¶
Generator[Array[T] ref] box
shuffled_array_gen[T: T]¶
[Source]
fun box shuffled_array_gen[T: T](
gen: Generator[Array[T] ref] box)
: Generator[Array[T] ref] box
Parameters¶
gen: Generator[Array[T] ref] box
Returns¶
Generator[Array[T] ref] box
shuffled_iter[T: T]¶
[Source]
fun box shuffled_iter[T: T](
array: Array[T] ref)
: Generator[Iterator[this->T!] ref] box
Parameters¶
array: Array[T] ref
Returns¶
Generator[Iterator[this->T!] ref] box
list_of[T: T]¶
[Source]
fun box list_of[T: T](
gen: Generator[T] box,
min: USize val = 0,
max: USize val = 100)
: Generator[List[T] ref] box
Parameters¶
gen: Generator[T] box
min: USize val = 0
max: USize val = 100
Returns¶
Generator[List[T] ref] box
set_of[T: (Hashable #read & Equatable[T] #read)]¶
[Source]
Create a generator for Set filled with values
of the given generator gen.
The returned sets will have a size up to max,
but tend to have fewer than max
depending on the source generator gen.
E.g. if the given generator is for U8 values and max is set to 1024,
the set will only ever be of size 256 max.
Also for efficiency purposes and to not loop forever,
this generator will only try to add at most max values to the set.
If there are duplicates, the set won't grow.
fun box set_of[T: (Hashable #read & Equatable[T] #read)](
gen: Generator[T] box,
max: USize val = 100)
: Generator[HashSet[T, HashEq[T] val] ref] box
Parameters¶
gen: Generator[T] box
max: USize val = 100
Returns¶
Generator[HashSet[T, HashEq[T] val] ref] box
set_is_of[T: T]¶
[Source]
Create a generator for SetIs filled with values
of the given generator gen.
The returned SetIs will have a size up to max,
but tend to have fewer entries
depending on the source generator gen.
E.g. if the given generator is for U8 values and max is set to 1024
the set will only ever be of size 256 max.
Also for efficiency purposes and to not loop forever,
this generator will only try to add at most max values to the set.
If there are duplicates, the set won't grow.
fun box set_is_of[T: T](
gen: Generator[T] box,
max: USize val = 100)
: Generator[HashSet[T, HashIs[T!] val] ref] box
Parameters¶
gen: Generator[T] box
max: USize val = 100
Returns¶
Generator[HashSet[T, HashIs[T!] val] ref] box
map_of[K: (Hashable #read & Equatable[K] #read), V: V]¶
[Source]
Create a generator for Map from a generator of key-value tuples.
The generated maps will have a size up to max,
but tend to have fewer entries depending on the source generator gen.
If the generator generates key-value pairs with
duplicate keys (based on structural equality),
the pair that is generated later will overwrite earlier entries in the map.
fun box map_of[K: (Hashable #read & Equatable[K] #read), V: V](
gen: Generator[(K , V)] box,
max: USize val = 100)
: Generator[HashMap[K, V, HashEq[K] val] ref] box
Parameters¶
gen: Generator[(K , V)] box
max: USize val = 100
Returns¶
Generator[HashMap[K, V, HashEq[K] val] ref] box
map_is_of[K: K, V: V]¶
[Source]
Create a generator for MapIs from a generator of key-value tuples.
The generated maps will have a size up to max,
but tend to have fewer entries depending on the source generator gen.
If the generator generates key-value pairs with
duplicate keys (based on identity),
the pair that is generated later will overwrite earlier entries in the map.
fun box map_is_of[K: K, V: V](
gen: Generator[(K , V)] box,
max: USize val = 100)
: Generator[HashMap[K, V, HashIs[K] val] ref] box
Parameters¶
gen: Generator[(K , V)] box
max: USize val = 100
Returns¶
Generator[HashMap[K, V, HashIs[K] val] ref] box
one_of[T: T]¶
[Source]
Generate a random value from the given ReadSeq.
This generator will generate nothing if the given xs is empty.
Generators created with this method do not support shrinking.
If do_shrink is set to true, it will return the same value
for each shrink round. Otherwise it will return nothing.
fun box one_of[T: T](
xs: ReadSeq[T] box,
do_shrink: Bool val = false)
: Generator[box->T] box
Parameters¶
xs: ReadSeq[T] box
do_shrink: Bool val = false
Returns¶
Generator[box->T] box
one_of_safe[T: T]¶
[Source]
Version of one_of that will error if xs is empty.
fun box one_of_safe[T: T](
xs: ReadSeq[T] box,
do_shrink: Bool val = false)
: Generator[box->T] box ?
Parameters¶
xs: ReadSeq[T] box
do_shrink: Bool val = false
Returns¶
Generator[box->T] box ?
frequency[T: T]¶
[Source]
Choose a value of one of the given Generators,
while controlling the distribution with the associated weights.
The weights are of type USize and control how likely a value is chosen.
The likelihood of a value v to be chosen
is weight_v / weights_sum.
If all weighted_generators have equal size the distribution
will be uniform.
Example of a generator to output odd U8 values
twice as likely as even ones:
Generators.frequency[U8]([
(1, Generators.u8().filter({(u) => (u, (u % 2) == 0 }))
(2, Generators.u8().filter({(u) => (u, (u % 2) != 0 }))
])
fun box frequency[T: T](
weighted_generators: ReadSeq[(USize val , Generator[T] box)] box)
: Generator[T] box
Parameters¶
weighted_generators: ReadSeq[(USize val , Generator[T] box)] box
Returns¶
Generator[T] box
frequency_safe[T: T]¶
[Source]
Version of frequency that errors if the given weighted_generators is
empty.
fun box frequency_safe[T: T](
weighted_generators: ReadSeq[(USize val , Generator[T] box)] box)
: Generator[T] box ?
Parameters¶
weighted_generators: ReadSeq[(USize val , Generator[T] box)] box
Returns¶
Generator[T] box ?
zip2[T1: T1, T2: T2]¶
[Source]
Zip two generators into a generator of a 2-tuple
containing the values generated by both generators.
fun box zip2[T1: T1, T2: T2](
gen1: Generator[T1] box,
gen2: Generator[T2] box)
: Generator[(T1 , T2)] box
Parameters¶
gen1: Generator[T1] box
gen2: Generator[T2] box
Returns¶
Generator[(T1 , T2)] box
zip3[T1: T1, T2: T2, T3: T3]¶
[Source]
Zip three generators into a generator of a 3-tuple
containing the values generated by those three generators.
fun box zip3[T1: T1, T2: T2, T3: T3](
gen1: Generator[T1] box,
gen2: Generator[T2] box,
gen3: Generator[T3] box)
: Generator[(T1 , T2 , T3)] box
Parameters¶
gen1: Generator[T1] box
gen2: Generator[T2] box
gen3: Generator[T3] box
Returns¶
Generator[(T1 , T2 , T3)] box
zip4[T1: T1, T2: T2, T3: T3, T4: T4]¶
[Source]
Zip four generators into a generator of a 4-tuple
containing the values generated by those four generators.
fun box zip4[T1: T1, T2: T2, T3: T3, T4: T4](
gen1: Generator[T1] box,
gen2: Generator[T2] box,
gen3: Generator[T3] box,
gen4: Generator[T4] box)
: Generator[(T1 , T2 , T3 , T4)] box
Parameters¶
gen1: Generator[T1] box
gen2: Generator[T2] box
gen3: Generator[T3] box
gen4: Generator[T4] box
Returns¶
Generator[(T1 , T2 , T3 , T4)] box
map2[T1: T1, T2: T2, T3: T3]¶
[Source]
Convenience combinator for mapping 2 generators into 1.
fun box map2[T1: T1, T2: T2, T3: T3](
gen1: Generator[T1] box,
gen2: Generator[T2] box,
fn: {(T1, T2): T3^}[T1, T2, T3] ref)
: Generator[T3] box
Parameters¶
gen1: Generator[T1] box
gen2: Generator[T2] box
fn: {(T1, T2): T3^}[T1, T2, T3] ref
Returns¶
Generator[T3] box
map3[T1: T1, T2: T2, T3: T3, T4: T4]¶
[Source]
Convenience combinator for mapping 3 generators into 1.
fun box map3[T1: T1, T2: T2, T3: T3, T4: T4](
gen1: Generator[T1] box,
gen2: Generator[T2] box,
gen3: Generator[T3] box,
fn: {(T1, T2, T3): T4^}[T1, T2, T3, T4] ref)
: Generator[T4] box
Parameters¶
gen1: Generator[T1] box
gen2: Generator[T2] box
gen3: Generator[T3] box
fn: {(T1, T2, T3): T4^}[T1, T2, T3, T4] ref
Returns¶
Generator[T4] box
map4[T1: T1, T2: T2, T3: T3, T4: T4, T5: T5]¶
[Source]
Convenience combinator for mapping 4 generators into 1.
fun box map4[T1: T1, T2: T2, T3: T3, T4: T4, T5: T5](
gen1: Generator[T1] box,
gen2: Generator[T2] box,
gen3: Generator[T3] box,
gen4: Generator[T4] box,
fn: {(T1, T2, T3, T4): T5^}[T1, T2, T3, T4, T5] ref)
: Generator[T5] box
Parameters¶
gen1: Generator[T1] box
gen2: Generator[T2] box
gen3: Generator[T3] box
gen4: Generator[T4] box
fn: {(T1, T2, T3, T4): T5^}[T1, T2, T3, T4, T5] ref
Returns¶
Generator[T5] box
bool¶
[Source]
Create a generator of bool values.
fun box bool()
: Generator[Bool val] box
Returns¶
Generator[Bool val] box
u8¶
[Source]
Create a generator for U8 values.
fun box u8(
min: U8 val = call,
max: U8 val = call)
: Generator[U8 val] box
Parameters¶
min: U8 val = call
max: U8 val = call
Returns¶
Generator[U8 val] box
u16¶
[Source]
create a generator for U16 values
fun box u16(
min: U16 val = call,
max: U16 val = call)
: Generator[U16 val] box
Parameters¶
min: U16 val = call
max: U16 val = call
Returns¶
Generator[U16 val] box
u32¶
[Source]
Create a generator for U32 values.
fun box u32(
min: U32 val = call,
max: U32 val = call)
: Generator[U32 val] box
Parameters¶
min: U32 val = call
max: U32 val = call
Returns¶
Generator[U32 val] box
u64¶
[Source]
Create a generator for U64 values.
fun box u64(
min: U64 val = call,
max: U64 val = call)
: Generator[U64 val] box
Parameters¶
min: U64 val = call
max: U64 val = call
Returns¶
Generator[U64 val] box
u128¶
[Source]
Create a generator for U128 values.
fun box u128(
min: U128 val = call,
max: U128 val = call)
: Generator[U128 val] box
Parameters¶
min: U128 val = call
max: U128 val = call
Returns¶
Generator[U128 val] box
usize¶
[Source]
Create a generator for USize values.
fun box usize(
min: USize val = call,
max: USize val = call)
: Generator[USize val] box
Parameters¶
min: USize val = call
max: USize val = call
Returns¶
Generator[USize val] box
ulong¶
[Source]
Create a generator for ULong values.
fun box ulong(
min: ULong val = call,
max: ULong val = call)
: Generator[ULong val] box
Parameters¶
min: ULong val = call
max: ULong val = call
Returns¶
Generator[ULong val] box
i8¶
[Source]
Create a generator for I8 values.
fun box i8(
min: I8 val = call,
max: I8 val = call)
: Generator[I8 val] box
Parameters¶
min: I8 val = call
max: I8 val = call
Returns¶
Generator[I8 val] box
i16¶
[Source]
Create a generator for I16 values.
fun box i16(
min: I16 val = call,
max: I16 val = call)
: Generator[I16 val] box
Parameters¶
min: I16 val = call
max: I16 val = call
Returns¶
Generator[I16 val] box
i32¶
[Source]
Create a generator for I32 values.
fun box i32(
min: I32 val = call,
max: I32 val = call)
: Generator[I32 val] box
Parameters¶
min: I32 val = call
max: I32 val = call
Returns¶
Generator[I32 val] box
i64¶
[Source]
Create a generator for I64 values.
fun box i64(
min: I64 val = call,
max: I64 val = call)
: Generator[I64 val] box
Parameters¶
min: I64 val = call
max: I64 val = call
Returns¶
Generator[I64 val] box
i128¶
[Source]
Create a generator for I128 values.
fun box i128(
min: I128 val = call,
max: I128 val = call)
: Generator[I128 val] box
Parameters¶
min: I128 val = call
max: I128 val = call
Returns¶
Generator[I128 val] box
ilong¶
[Source]
Create a generator for ILong values.
fun box ilong(
min: ILong val = call,
max: ILong val = call)
: Generator[ILong val] box
Parameters¶
min: ILong val = call
max: ILong val = call
Returns¶
Generator[ILong val] box
isize¶
[Source]
Create a generator for ISize values.
fun box isize(
min: ISize val = call,
max: ISize val = call)
: Generator[ISize val] box
Parameters¶
min: ISize val = call
max: ISize val = call
Returns¶
Generator[ISize val] box
byte_string¶
[Source]
Create a generator for strings
generated from the bytes returned by the generator gen,
with a minimum length of min (default: 0)
and a maximum length of max (default: 100).
fun box byte_string(
gen: Generator[U8 val] box,
min: USize val = 0,
max: USize val = 100)
: Generator[String val] box
Parameters¶
gen: Generator[U8 val] box
min: USize val = 0
max: USize val = 100
Returns¶
Generator[String val] box
ascii¶
[Source]
Create a generator for strings withing the given range,
with a minimum length of min (default: 0)
and a maximum length of max (default: 100).
fun box ascii(
min: USize val = 0,
max: USize val = 100,
range: (ASCIINUL val | ASCIIDigits val | ASCIIWhiteSpace val |
ASCIIPunctuation val | ASCIILettersLower val | ASCIILettersUpper val |
ASCIILetters val | ASCIIPrintable val | ASCIINonPrintable val |
ASCIIAll val | ASCIIAllWithNUL val) = reference)
: Generator[String val] box
Parameters¶
min: USize val = 0
max: USize val = 100
range: (ASCIINUL val | ASCIIDigits val | ASCIIWhiteSpace val |
ASCIIPunctuation val | ASCIILettersLower val | ASCIILettersUpper val |
ASCIILetters val | ASCIIPrintable val | ASCIINonPrintable val |
ASCIIAll val | ASCIIAllWithNUL val) = reference
Returns¶
Generator[String val] box
ascii_printable¶
[Source]
Create a generator for strings of printable ASCII characters,
with a minimum length of min (default: 0)
and a maximum length of max (default: 100).
fun box ascii_printable(
min: USize val = 0,
max: USize val = 100)
: Generator[String val] box
Parameters¶
min: USize val = 0
max: USize val = 100
Returns¶
Generator[String val] box
ascii_numeric¶
[Source]
Create a generator for strings of numeric ASCII characters,
with a minimum length of min (default: 0)
and a maximum length of max (default: 100).
fun box ascii_numeric(
min: USize val = 0,
max: USize val = 100)
: Generator[String val] box
Parameters¶
min: USize val = 0
max: USize val = 100
Returns¶
Generator[String val] box
ascii_letters¶
[Source]
Create a generator for strings of ASCII letters,
with a minimum length of min (default: 0)
and a maximum length of max (default: 100).
fun box ascii_letters(
min: USize val = 0,
max: USize val = 100)
: Generator[String val] box
Parameters¶
min: USize val = 0
max: USize val = 100
Returns¶
Generator[String val] box
utf32_codepoint_string¶
[Source]
Create a generator for strings
from a generator of unicode codepoints,
with a minimum length of min codepoints (default: 0)
and a maximum length of max codepoints (default: 100).
Note that the byte length of the generated string can be up to 4 times
the size in code points.
fun box utf32_codepoint_string(
gen: Generator[U32 val] box,
min: USize val = 0,
max: USize val = 100)
: Generator[String val] box
Parameters¶
gen: Generator[U32 val] box
min: USize val = 0
max: USize val = 100
Returns¶
Generator[String val] box
unicode¶
[Source]
Create a generator for unicode strings,
with a minimum length of min codepoints (default: 0)
and a maximum length of max codepoints (default: 100).
Note that the byte length of the generated string can be up to 4 times
the size in code points.
fun box unicode(
min: USize val = 0,
max: USize val = 100)
: Generator[String val] box
Parameters¶
min: USize val = 0
max: USize val = 100
Returns¶
Generator[String val] box
unicode_bmp¶
[Source]
Create a generator for unicode strings
from the basic multilingual plane only,
with a minimum length of min codepoints (default: 0)
and a maximum length of max codepoints (default: 100).
Note that the byte length of the generated string can be up to 4 times
the size in code points.
fun box unicode_bmp(
min: USize val = 0,
max: USize val = 100)
: Generator[String val] box
Parameters¶
min: USize val = 0
max: USize val = 100
Returns¶
Generator[String val] box
eq¶
[Source]
fun box eq(
that: Generators val)
: Bool val
Parameters¶
that: Generators val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: Generators val)
: Bool val
Parameters¶
that: Generators val
Returns¶
Bool val
| pony | 244216 | https://sv.wikipedia.org/wiki/Gammaplex | Gammaplex | Gammaplex är ett tvådimensionellt programspråk utvecklat av Lode Vandevenne. Gammaplex har många funktioner inbyggda, bland annat grafisk utmatning och musklick. Interpretatorn är licensierad under BSD-licensen.
Exempel
Ett mandelbrot-program i Gammaplex.
@ 200)u150)l1a0#0}>1a{"}4#0XG v
Mandelbrot by ^ v?,y(]0 <
Lode Vandevenne >1a{s"sN}v
v0.1 ^ E?,h(]1R<
0](y2:-1.5*0.5y*:0.5-30]) \
1](h2:-0.5h*:31]) \
32]0)u0)u0)u0)u0) \
>36](")34](32])35](33])32](w*33](\
w*-30](+34])2#32](*33](*31](+35])\
34](w*35](w*+4,?v36](16,?v7#0G \
G0#11< >12#0G \
>255#255#36](16*H3a}PXg
>128#128#128#3a}PXg
Externa länkar
Gammaplex
Programspråk | swedish | 0.910588 |
Pony/src-process-_process-.txt |
_process.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456use "signals"
use "files"
use @pony_os_errno[I32]()
use @ponyint_wnohang[I32]() if posix
use @ponyint_win_process_create[USize](appname: Pointer[U8] tag,
cmdline: Pointer[U8] tag, environ: Pointer[U8] tag, wdir: Pointer[U8] tag,
stdin_fd: U32, stdout_fd: U32, stderr_fd: U32,
error_code: Pointer[U32], error_msg: Pointer[Pointer[U8]] tag)
use @ponyint_win_process_wait[I32](hProc: USize, code: Pointer[I32])
use @ponyint_win_process_kill[I32](hProc: USize)
use @execve[I32](path: Pointer[U8] tag, argp: Pointer[Pointer[U8] tag] tag,
envp: Pointer[Pointer[U8] tag] tag)
use @fork[I32]()
use @chdir[I32](path: Pointer[U8] tag)
use @dup2[I32](fildes: U32, fildes2: U32)
use @write[ISize](fd: U32, buf: Pointer[U8] tag, size: USize)
use @kill[I32](pid_t: I32, sig: U32)
use @waitpid[I32](pid: I32, stat_loc: Pointer[I32] tag, opts: I32)
use @_exit[None](status: I32)
// for Windows System Error Codes see: https://docs.microsoft.com/de-de/windows/desktop/Debug/system-error-codes
primitive _ERRORBADEXEFORMAT
fun apply(): U32 =>
"""
ERROR_BAD_EXE_FORMAT
%1 is not a valid Win32 application.
"""
193 // 0xC1
primitive _ERRORDIRECTORY
fun apply(): U32 =>
"""
The directory name is invalid.
"""
267 // 0x10B
primitive _STDINFILENO
fun apply(): U32 => 0
primitive _STDOUTFILENO
fun apply(): U32 => 1
primitive _STDERRFILENO
fun apply(): U32 => 2
// Operation not permitted
primitive _EPERM
fun apply(): I32 => 1
// No such process
primitive _ESRCH
fun apply(): I32 => 3
// Interrupted function
primitive _EINTR
fun apply(): I32 => 4
// Try again
primitive _EAGAIN
fun apply(): I32 =>
ifdef bsd or osx then 35
elseif linux then 11
elseif windows then 22
else compile_error "no EAGAIN" end
// Invalid argument
primitive _EINVAL
fun apply(): I32 => 22
primitive _EXOSERR
fun apply(): I32 => 71
// For handling errors between @fork and @execve
primitive _StepChdir
fun apply(): U8 => 1
primitive _StepExecve
fun apply(): U8 => 2
primitive _WNOHANG
fun apply(): I32 =>
ifdef posix then
@ponyint_wnohang()
else
compile_error "no clue what WNOHANG is on this platform."
end
class val Exited is (Stringable & Equatable[ProcessExitStatus])
"""
Process exit status: Process exited with an exit code.
"""
let _exit_code: I32
new val create(code: I32) =>
_exit_code = code
fun exit_code(): I32 =>
"""
Retrieve the exit code of the exited process.
"""
_exit_code
fun string(): String iso^ =>
recover iso
String(10)
.>append("Exited(")
.>append(_exit_code.string())
.>append(")")
end
fun eq(other: ProcessExitStatus): Bool =>
match other
| let e: Exited =>
e._exit_code == _exit_code
else
false
end
class val Signaled is (Stringable & Equatable[ProcessExitStatus])
"""
Process exit status: Process was terminated by a signal.
"""
let _signal: U32
new val create(sig: U32) =>
_signal = sig
fun signal(): U32 =>
"""
Retrieve the signal number that exited the process.
"""
_signal
fun string(): String iso^ =>
recover iso
String(12)
.>append("Signaled(")
.>append(_signal.string())
.>append(")")
end
fun eq(other: ProcessExitStatus): Bool =>
match other
| let s: Signaled =>
s._signal == _signal
else
false
end
type ProcessExitStatus is (Exited | Signaled)
"""
Representing possible exit states of processes.
A process either exited with an exit code or, only on posix systems,
has been terminated by a signal.
"""
primitive _StillRunning
type _WaitResult is (ProcessExitStatus | WaitpidError | _StillRunning)
interface _Process
fun kill()
fun ref wait(): _WaitResult
"""
Only polls, does not actually wait for the process to finish,
in order to not block a scheduler thread.
"""
class _ProcessNone is _Process
fun kill() => None
fun ref wait(): _WaitResult => Exited(255)
class _ProcessPosix is _Process
let pid: I32
new create(
path: String,
args: Array[String] val,
vars: Array[String] val,
wdir: (FilePath | None),
err: _Pipe,
stdin: _Pipe,
stdout: _Pipe,
stderr: _Pipe) ?
=>
// Prepare argp and envp ahead of fork() as it's not safe to allocate in
// the child after fork() is called.
let argp = _make_argv(args)
let envp = _make_argv(vars)
// Fork the child process, handling errors and the child fork case.
pid = @fork()
match pid
| -1 => error
| 0 => _child_fork(path, argp, envp, wdir, err, stdin, stdout, stderr)
end
fun tag _make_argv(args: Array[String] box): Array[Pointer[U8] tag] =>
"""
Convert an array of String parameters into an array of
C pointers to same strings.
"""
let argv = Array[Pointer[U8] tag](args.size() + 1)
for s in args.values() do
argv.push(s.cstring())
end
argv.push(Pointer[U8]) // nullpointer to terminate list of args
argv
fun _child_fork(
path: String,
argp: Array[Pointer[U8] tag],
envp: Array[Pointer[U8] tag],
wdir: (FilePath | None),
err: _Pipe, stdin: _Pipe, stdout: _Pipe, stderr: _Pipe)
=>
"""
We are now in the child process. We redirect STDIN, STDOUT and STDERR
to their pipes and execute the command. The command is executed via
execve which does not return on success, and the text, data, bss, and
stack of the calling process are overwritten by that of the program
loaded. We've set the FD_CLOEXEC flag on all file descriptors to ensure
that they are all closed automatically once @execve gets called.
"""
_dup2(stdin.far_fd, _STDINFILENO()) // redirect stdin
_dup2(stdout.far_fd, _STDOUTFILENO()) // redirect stdout
_dup2(stderr.far_fd, _STDERRFILENO()) // redirect stderr
var step: U8 = _StepChdir()
match wdir
| let d: FilePath =>
let dir: Pointer[U8] tag = d.path.cstring()
if 0 > @chdir(dir) then
@write(err.far_fd, addressof step, USize(1))
@_exit(_EXOSERR())
end
| None => None
end
step = _StepExecve()
if 0 > @execve(path.cstring(), argp.cpointer(),
envp.cpointer())
then
@write(err.far_fd, addressof step, USize(1))
@_exit(_EXOSERR())
end
fun tag _dup2(oldfd: U32, newfd: U32) =>
"""
Creates a copy of the file descriptor oldfd using the file
descriptor number specified in newfd. If the file descriptor newfd
was previously open, it is silently closed before being reused.
If dup2() fails because of EINTR we retry.
"""
while (@dup2(oldfd, newfd) < 0) do
if @pony_os_errno() == _EINTR() then
continue
else
@_exit(I32(-1))
end
end
fun kill() =>
"""
Terminate the process, first trying SIGTERM and if that fails, try SIGKILL.
"""
if pid > 0 then
// Try a graceful termination
if @kill(pid, Sig.term()) < 0 then
match @pony_os_errno()
| _EINVAL() => None // Invalid argument, shouldn't happen but
// tryinng SIGKILL isn't likely to help.
| _ESRCH() => None // No such process, child has terminated
else
// Couldn't SIGTERM, as a last resort SIGKILL
@kill(pid, Sig.kill())
end
end
end
fun ref wait(): _WaitResult =>
"""Only polls, does not block."""
if pid > 0 then
var wstatus: I32 = 0
let options: I32 = 0 or _WNOHANG()
// poll, do not block
match @waitpid(pid, addressof wstatus, options)
| let err: I32 if err < 0 =>
// one could possibly do at some point:
//let wpe = WaitPidError(@pony_os_errno())
WaitpidError
| let exited_pid: I32 if exited_pid == pid => // our process changed state
if _WaitPidStatus.exited(wstatus) then
Exited(_WaitPidStatus.exit_code(wstatus))
elseif _WaitPidStatus.signaled(wstatus) then
Signaled(_WaitPidStatus.termsig(wstatus).u32())
elseif _WaitPidStatus.stopped(wstatus) then
Signaled(_WaitPidStatus.stopsig(wstatus).u32())
elseif _WaitPidStatus.continued(wstatus) then
_StillRunning
else
// *shrug*
WaitpidError
end
| 0 => _StillRunning
else
WaitpidError
end
else
WaitpidError
end
primitive _WaitPidStatus
"""
Pure Pony implementaton of C macros for investigating
the status returned by `waitpid()`.
"""
fun exited(wstatus: I32): Bool =>
termsig(wstatus) == 0
fun exit_code(wstatus: I32): I32 =>
(wstatus and 0xff00) >> 8
fun signaled(wstatus: I32): Bool =>
((termsig(wstatus) + 1) >> 1).i8() > 0
fun termsig(wstatus: I32): I32 =>
(wstatus and 0x7f)
fun stopped(wstatus: I32): Bool =>
(wstatus and 0xff) == 0x7f
fun stopsig(wstatus: I32): I32 =>
exit_code(wstatus)
fun coredumped(wstatus: I32): Bool =>
(wstatus and 0x80) != 0
fun continued(wstatus: I32): Bool =>
wstatus == 0xffff
class _ProcessWindows is _Process
let h_process: USize
let process_error: (ProcessError | None)
var final_wait_result: (_WaitResult | None) = None
new create(
path: String,
args: Array[String] val,
vars: Array[String] val,
wdir: (FilePath | None),
stdin: _Pipe,
stdout: _Pipe,
stderr: _Pipe)
=>
ifdef windows then
let wdir_ptr =
match wdir
| let wdir_fp: FilePath => wdir_fp.path.cstring()
| None => Pointer[U8] // NULL -> use parent directory
end
var error_code: U32 = 0
var error_message = Pointer[U8]
h_process = @ponyint_win_process_create(
path.cstring(),
_make_cmdline(args).cstring(),
_make_environ(vars).cpointer(),
wdir_ptr,
stdin.far_fd, stdout.far_fd, stderr.far_fd,
addressof error_code, addressof error_message)
process_error =
if h_process == 0 then
match error_code
| _ERRORBADEXEFORMAT() => ProcessError(ExecveError)
| _ERRORDIRECTORY() =>
let wdirpath =
match wdir
| let wdir_fp: FilePath => wdir_fp.path
| None => "?"
end
ProcessError(ChdirError, "Failed to change directory to "
+ wdirpath)
else
let message = String.from_cstring(error_message)
ProcessError(ForkError, recover message.clone() end)
end
end
else
compile_error "unsupported platform"
end
fun tag _make_cmdline(args: Array[String] val): String =>
var cmdline: String = ""
for arg in args.values() do
// quote args with spaces on Windows
var next = arg
ifdef windows then
try
if arg.contains(" ") and (not arg(0)? == '"') then
next = "\"" + arg + "\""
end
end
end
cmdline = cmdline + next + " "
end
cmdline
fun tag _make_environ(vars: Array[String] val): Array[U8] =>
var size: USize = 0
for varr in vars.values() do
size = size + varr.size() + 1 // name=value\0
end
size = size + 1 // last \0
var environ = Array[U8](size)
for varr in vars.values() do
environ.append(varr)
environ.push(0)
end
environ.push(0)
environ
fun kill() =>
if h_process != 0 then
@ponyint_win_process_kill(h_process)
end
fun ref wait(): _WaitResult =>
match final_wait_result
| let wr: _WaitResult =>
wr
else
var wr: _WaitResult = WaitpidError
if h_process != 0 then
var exit_code: I32 = 0
match @ponyint_win_process_wait(h_process, addressof exit_code)
| 0 =>
wr = Exited(exit_code)
final_wait_result = wr
wr
| 1 => _StillRunning
| let code: I32 =>
// we might want to propagate that code to the user, but should it do
// for other errors too
final_wait_result = wr
wr
end
else
final_wait_result = wr
wr
end
end
| pony | 1107401 | https://no.wikipedia.org/wiki/Liste%20over%20nummererte%20sm%C3%A5planeter%3A%203001%E2%80%934000 | Liste over nummererte småplaneter: 3001–4000 | Liste over nummererte småplaneter: 3001–4000 er en liste over nummererte småplaneter fra nummer 3001–4000. For fullstendig liste, se liste over nummererte småplaneter.
! colspan="5" style="background-color:silver;text-align:center;" id="001"| 3001–3100 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="101"| 3101–3200 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="201"| 3201–3300 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="301"| 3301–3400 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="401"| 3401–3500 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="501"| 3501–3600 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="601"| 3601–3700 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="701"| 3701–3800 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="801"| 3801–3900 [ rediger]
! colspan="5" style="background-color:silver;text-align:center;" id="901"| 3901–4000 [ rediger]
Eksterne lenker
Liste over nummererte småplaneter (003001-004000)
Artikler i astronomiprosjektet | norwegian_bokmål | 0.931332 |
Pony/buffered--index-.txt |
Buffered Package¶
The Buffered package provides two classes, Writer and Reader, for
writing and reading messages using common encodings. These classes are
useful when dealing with things like network data and binary file
formats.
Example program¶
use "buffered"
actor Main
new create(env: Env) =>
let reader = Reader
let writer = Writer
writer.u32_be(42)
writer.f32_be(3.14)
let b = recover iso Array[U8] end
for chunk in writer.done().values() do
b.append(chunk)
end
reader.append(consume b)
try
env.out.print(reader.u32_be()?.string()) // prints 42
env.out.print(reader.f32_be()?.string()) // prints 3.14
end
Public Types¶
class Reader
class Writer
| pony | 449875 | https://da.wikipedia.org/wiki/E-bogsl%C3%A6ser | E-bogslæser | En e-bogslæser, elektronisk boglæser eller digital boglæser er et apparat eller software til at læse elektroniske bøger (e-bøger) med. Der er forskellige apparater, på hvilke man kan læse en e-bog, disse kan være dedikerede e-bogslæser eller software baserede e-bogslæsere.
Dedikeret e-bogslæser
En dedikeret e-bogslæser er designet til at kunne virke i lang tid på batteridrift. Udlæsningsenheden/Skærmen skal kunne læses i solskin og indendørs i standardbelysning. Nogle e-bogslæsere har indbygget læselys. Aktuelle e-læser skærme kan kun vise stationære gråtoner.
Nogle, men ikke alle e-bogslæsere, bruger det vidt udbredte e-bogs format EPUB, andre bruger proprietære/egne formater.
På det danske marked findes der bl.a. i 2013:
Amazon Kindle
Cybook Opus
iRiver Story HD
Kobo Aura HD
Nook Simple Touch
Pocketbook Touch Lux
Sony Reader PRS-T3
Icarus Essence E602BK
Farver
Reelt set burde det ikke være nødvendigt med en farveskærm for at læse tekst, men farver kan være relevante hvis bogen indeholder farveillustrationer.
Det Qualcomm ejede Mirasol har lavet en farveskærm som kan vise video og den vil kunne anvendes i e-læsere pga. det lave strømforbrug.
Fujitsu har offentliggjort en e-læser – Flepia – med farveskærm, der kan holde til 40 timers brug på en opladning.
HP melder om gennembrud med elektronisk papir med farver.
Software baserede e-bogslæsere
De software baserede e-bogslæsere er apparater, der også har andre funktioner end at læse e-bøger, dette kunne være:
Tablets
Smartphones
PC'er
PDA'er
Eksterne henvisninger
List of the main e-book readers and their general characteristics
pcworld.com: Top 5 E-Book Readers
Kilder
E-bøger | danish | 0.914083 |
Pony/serialise-SerialiseAuth-.txt |
SerialiseAuth¶
[Source]
This is a capability that allows the holder to serialise objects. It does not
allow the holder to examine serialised data or to deserialise objects.
primitive val SerialiseAuth
Constructors¶
create¶
[Source]
new val create(
auth: AmbientAuth val)
: SerialiseAuth val^
Parameters¶
auth: AmbientAuth val
Returns¶
SerialiseAuth val^
Public Functions¶
eq¶
[Source]
fun box eq(
that: SerialiseAuth val)
: Bool val
Parameters¶
that: SerialiseAuth val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: SerialiseAuth val)
: Bool val
Parameters¶
that: SerialiseAuth val
Returns¶
Bool val
| pony | 6122529 | https://sv.wikipedia.org/wiki/%C7%82Kx%CA%BCau%C7%81%CA%BCein | ǂKxʼauǁʼein | ǂKxʼauǁʼein, även ǂKxʼauǁʼei, ǁAuǁei, ǁXʼauǁʼe, Auen, Kaukau, Koko, Kung-Gobabis, är ett khoisanspråk med 7000 talare, varav 4000 i Namibia och 3000 i Botswana (2006).
Källor
ǂKxʼauǁʼein på Ethnologue
Khoisanspråk
Språk i Botswana
Språk i Namibia | swedish | 1.163281 |
Pony/files-FileChmod-.txt |
FileChmod¶
[Source]
primitive val FileChmod
Constructors¶
create¶
[Source]
new val create()
: FileChmod val^
Returns¶
FileChmod val^
Public Functions¶
value¶
[Source]
fun box value()
: U32 val
Returns¶
U32 val
eq¶
[Source]
fun box eq(
that: FileChmod val)
: Bool val
Parameters¶
that: FileChmod val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FileChmod val)
: Bool val
Parameters¶
that: FileChmod val
Returns¶
Bool val
| pony | 100682 | https://sv.wikipedia.org/wiki/Terr%C3%A4ngbil%2011/13 | Terrängbil 11/13 | Terrängbil 11 (Tgb 11, Volvo C303) och Terrängbil 13 (Tgb 13, Volvo C304), är två vanliga terrängbilsversioner inom Försvarsmakten. Vanligtvis kallas de bara 11-bil eller 13-bil.
Bakgrund
Terrängbil 11 och dess övriga versioner är en vidareutveckling av Volvos tidigare Pltgb 903 (personlastterrängbil 903) som populärt kallades "Valpen". Tillverkad av Volvo för Svenska försvaret. I den svenska terrängen är det fördelaktigare med relativt smala fordon än bredare fordon som till exempel HMMWV som skulle ha stora svårigheter att kunna komma fram längs de smala skogsstigarna.
Tgb 11 har två axlar, medan Tgb 13 och 20 har tre. Fordonen driver normalt sett bara på bakhjulen, men framhjulen kan kopplas in för att få drivning på alla hjulen. Vakuumstyrda differentialspärrar finns även på alla modellerna.
För att få så hög markfrigång som möjligt används portalaxlar. Nackdelen med dessa är att fordonet får en högre tyngdpunkt.
Historia
Försvaret började under 1960-talet att diskutera om en ersättare till Pltgb 903. Det svenska, mycket varierande landskapet ställer höga krav på terrängframkomlighet. 1967 påbörjades arbetet kallat "Projekt 4140". Den nya terrängbilsgenerationen omfattade ett flertal varianter både två, tre och fyraxliga. Senare kom dock den fyraxliga åttahjulsdrivna och fyraxliga men sexhjulsdriva versionen att strykas ur programmet. Kvar blev de tvåaxliga fyrhjulsdrivna och treaxliga sexhjulsdrivna varianterna.
Civila fordon
De nya terrängfordonen blev populära efterträdare till "Valpen" hos landets räddningstjänster. Här användes de som slangutläggningsbilar, för sjuktransport, som materialtransportör, med mera. Även statliga verk, kraftbolag, med flera köpte dessa fordon till sin serviceorganisation. Fordonen såldes också utomlands, till exempel till Storbritannien där elektronikföretaget Pye inredde dem som OB-fordon för Télévision Algérienne i Algeriet.
Modeller
Det finns flera olika modeller av Volvo C300-serien, både militära och civila.
Tgb 11 (C303/4141)
Terrängbil 11 är grundversionen och har varit den vanligast förekommande militära bilen i Försvarsmakten.
PvPjTgb 1111 (C303/4151)
Pansarvärnspjästerrängbil 1111. Två axlar och en öppen kaross med fällbar störtbåge. Bilen är avsedd för pansarbekämpning med 9-centimeters Pansarvärnspjäs 1110.
Pvrbtgb RBS 56 (C303/4151)
Pansarvärnstrobotterrängbil Robot 56 (Pvrbtgb RBS 56 och i en senare version Pvrbtgb B RBS 56). Ombyggd Pvpjtgb 1111. Då Pansarvärnspjäs 1110 i början på 90-talet inte längre var effektiv mot nyare generationers stridsvagnar så byggs ett antal Pvpjtgb 1111 om till bärare av Pansarvärnsroboten Robot 56 Bill. Förändringarna innefattade utöver beväpningen även ny kaross med bakdörrar, en annan pjäshiss med plats för knästående skytt och stödben i varje hörn på fordonet. Utförande "B" har även fäste för Ksp 58/Ksp 90 för närskydd, fast RA 180/DART 380 och GPS.
Tgb 1112/1113 (C303/4141)
Terrängbil 1112/1113 är en radioterrängbil med två axlar, fem radioanslutningar (2 x ultrakortvåg, 2 x kortvåg, 1 x FM/lufor) och trådanslutningsmöjlighet. På grund av antennerna är takluckan flyttad bakåt och lavetten borttagen, dessutom får endast fem personer plats. I övrigt som standard Tgb 11.
Tgb 13 (C304/4143)
Terrängbil 13 är mycket lik Tgb 11, skillnaden är att Tgb 13 har två stycken drivande bakaxlar och är en meter längre i bakdelen. Därav även vissa prestandaskillnader.
Tgb 1312 (C304/-)
Terrängbil 1312 är en radiolänkterrängbil med tre axlar. Har en separat sambandshytt. Bilen har till uppgift att etablera samband med hjälp av radiolänk 340.
Tgb 1313 (C304/-)
Terrängbil 1313 är en stabsterrängbil med tre axlar och separat sambandshytt för stridsledning.
Tgb 1314A/1314B (C304/-)
Terrängbil 1314A/B är en sjukvårdstransportbil med tre axlar och separat extra rymligt sjukvårdsutrymme med plats för 4 stycken bårar och akututrustning.
Tgb 1315A/1315B (C304/-)
Terrängbil 1315A/B är en ambulans och utrustad med bår för en skadad och möjlighet att ta fyra civilförsvarsbårar. Full medicinsk utrustning (efter militära mått), blåljus och siren.
Tgb 1321A/1321B (C304/-)
Terrängbil 1321A/B är en batteriplatsbil med tre axlar och plats bakom förarutrymmet för en batteriplatsgrupp tillhörande ett artilleri eller granatkastarförband.
Prototyper
Prototyp Tgb 12 (C304/4142)
Amfibisk Tgb 13 med tre axlar (6x6). Under 1972–73 gjordes försök med 5 prototyper i "Projekt 4142". Dessa var en variant av Tgb 13 med luftintag och avgasrör rakt ovanför motorn. Taket hade delvis kapell för snabb evakuering. Framdrivning med vattenjetaggregat. Farten i vatten var 4,5 knop. Två exemplar finns bevarade. Modellen ströks ur programmet när det var dags för massproduktion på grund av kostnadsskäl.
Galleri
Se även
Terrängbil 14/15
Terrängbil 16
Terrängbil 20
Terrängbil 30/40
Referenser
Noter
Externa länkar
Terrängbil 11/13 på Soldf.com
https://web.archive.org/web/20090105214014/http://www.amphibiousvehicle.net/amphi/V/volvospecial/volvo.html
Militärfordon tillverkade av Volvo
Terrängfordon
Fordon i svenska armén
Fyrhjulsdrivna fordon
Allhjulsdrivna fordon | swedish | 1.14334 |
Pony/recovering-capabilities.txt | # Recovering Capabilities
A `recover` expression lets you "lift" the reference capability of the result. A mutable reference capability (`iso`, `trn`, or `ref`) can become _any_ reference capability, and an immutable reference capability (`val` or `box`) can become any immutable or opaque reference capability.
## Why is this useful?
This most straightforward use of `recover` is to get an `iso` that you can pass to another actor. But it can be used for many other things as well, such as:
* Creating a cyclic immutable data structure. That is, you can create a complex mutable data structure inside a `recover` expression, "lift" the resulting `ref` to a `val`.
* "Borrow" an `iso` as a `ref`, do a series of complex mutable operations on it, and return it as an `iso` again.
* "Extract" a mutable field from an `iso` and return it as an `iso`.
## What does this look like?
The `recover` expression wraps a list of expressions and is terminated by an `end`, like this:
```pony
recover Array[String].create() end
```
This expression returns an `Array[String] iso`, instead of the usual `Array[String] ref` you would get. The reason it is `iso` and not any of the other mutable reference capabilities is because there is a default reference capability when you don't specify one. The default for any mutable reference capability is `iso` and the default for any immutable reference capability is `val`.
Here's a more complicated example from the standard library:
```pony
recover
var s = String((prec + 1).max(width.max(31)))
var value = x
try
if value == 0 then
s.push(table(0)?)
else
while value != 0 do
let index = ((value = value / base) - (value * base))
s.push(table(index.usize())?)
end
end
end
_extend_digits(s, prec')
s.append(typestring)
s.append(prestring)
_pad(s, width, align, fill)
s
end
```
That's from `format/_FormatInt`. It creates a `String ref`, does a bunch of stuff with it, and finally returns it as a `String iso`.
You can also give an explicit reference capability:
```pony
let key = recover val line.substring(0, i).>strip() end
```
That's from `net/http/_PayloadBuilder`. We get a substring of `line`, which is a `String iso^`, then we call strip on it, which returns itself. But since strip is a `ref` function, it returns itself as a `String ref^` - so we use a `recover val` to end up with a `String val`.
## How does this work?
Inside the `recover` expression, your code only has access to __sendable__ values from the enclosing lexical scope. In other words, you can only use `iso`, `val` and `tag` things from outside the `recover` expression.
This means that when the `recover` expression finishes, any aliases to the result of the expression other than `iso`, `val` and `tag` ones won't exist anymore. That makes it safe to "lift" the reference capability of the result of the expression.
If the `recover` expression could access __non-sendable__ values from the enclosing lexical scope, "lifting" the reference capability of the result wouldn't be safe. Some of those values could "leak" into an `iso` or `val` result, and result in data races.
## Automatic receiver recovery
When you have an `iso` or `trn` receiver, you normally can't call `ref` methods on it. That's because the receiver is also an argument to a method, which means both the method body and the caller have access to the receiver at the same time. And _that_ means we have to alias the receiver when we call a method on it. The alias of an `iso` is a `tag` (which isn't a subtype of `ref`) and the alias of a `trn` is a `box` (also not a subtype of `ref`).
But we can get around this! If all the arguments to the method (other than the receiver, which is the implicit argument being recovered) _at the call-site_ are __sendable__, and the return type of the method is either __sendable__ or isn't used _at the call-site_, then we can "automatically recover" the receiver. That just means we don't have to alias the receiver - and _that_ means we can call `ref` methods on an `iso` or `trn`, since `iso` and `trn` are both subtypes of `ref`.
Notice that this technique looks mostly at the call-site, rather than at the definition of the method being called. That makes it more flexible. For example, if the method being called wants a `ref` argument, and we pass it an `iso` argument, that's __sendable__ at the call-site, so we can still do automatic receiver recovery.
This may sound a little complicated, but in practice, it means you can write code that treats an `iso` mostly like a `ref`, and the compiler will complain when it's wrong. For example:
```pony
let s = recover String end
s.append("hi")
```
Here, we create a `String iso` and then append some text to it. The append method takes a `ref` receiver and a `box` parameter. We can automatically recover the `iso` receiver since we pass a `val` parameter, so everything is fine.
| pony | 956363 | https://da.wikipedia.org/wiki/Subrutine | Subrutine | En subrutine er en samling computerinstruktionssætinstruktioner, evt. i form af nogle linjer i et programmeringssprog. Subrutinen udfører en bestemt opgave, som man har brug for at få udført ved kald fra forskellige steder i et computerprogram. Et kald af subrutinen er enklere og kræver mindre lager end alternativet at gentage nøjagtigt de samme instruktioner, hver gang de skal benyttes. Kald af subrutiner kan også benyttes for at strukturere et program ved opdeling i mindre dele, således at det bliver mere overskueligt.
Subrutiner, der vurderes at være generelt anvendelige, kan på forskellig vis placeres i ”biblioteker””, så de let kan genbruges i andre programmer, enten ved at inkludere subrutinens kode under oversættelsen, eller ved at linke til rutinen.
Forskellige betegnelser
Subrutiner betegnes i nogle programmeringssprog som funktioner eller procedurer. Inden for objektorienteret programmering benyttes betegnelser som metode eller service. Endelig kan man støde på betegnelsen underprogram. Forskellen på en metode og en procedure er, at en funktion returnerer en værdi knyttet til funktionens navn (funktionen kan direkte indgå i en tildeling/et assignment), mens en procedure ikke returnerer en sådan værdi. Til gengæld vil en procedure kunne (men behøver ikke) returnere adskillige resultater i sin parameterliste. I andre programmeringssprog skelnes der ikke strengt mellem funktioner og procedurer, evt. kan en procedure blot være en funktion med returværdi af typen void.
Man kan også udtrykke det således, at en funktion evalueres til en værdi, mens en procedure er en ny kommando. I begge tilfælde er der tale om en abstraktion, idet den der benytter et kald af en subrutine ikke behøver kende detaljerne i subrutinens kode. Og denne kode kan ændres, uden at det ødelægger noget for resten af systemet. Det er dog her en fornuftig regel, at en funktion ikke bør have sideeffekter (effekter for andre dele af systemet end den værdi der returneres). For en procedure bør data ind og ud kun ske via parameterlisten, så man kan se, hvad der røres ved. Ingen benyttelse af fælles, globale variable.
I nogle tilfælde vil man for at få en hurtige afvikling af programmet undgå kaldet, der altid medfører et ekstraarbejde (overhead), men i stedet gentage instruktionerne, der udgør kroppen på subrutine, i det færdige program. Dette kan foregå ved brug af en makro eller overlades til oversætteren.
Implementering
Når en subrutine kaldes, skal computeren gemme adressen på den instruktion, der følger umiddelbart efter kaldet af subrutinen, således at computeren kan vende tilbage til dette sted. Dette sker typisk derved, at cpu'en lagrer denne adresse i et særligt register (som eksempel kan nævnes branch-and-link(-register)-instruktionen på System/360 fra IBM), eller i andre computere ved at adressen, der er instruktionstælleren plus længden af instruktionskaldet, pushes på computerens stak, hvor den senere kan hentes igen. Der findes normalt også en form for "return-from-subroutine" instruktion.
Private data og rekursion
Hvis subrutinen er implementeret på en sådan måde, at den har variable, der er private for rutinen, og således at et nyt kald af rutinen fra rutinen selv medfører skabelsen af et nyt sæt private variable, kan man benytte rekursiv programmering. Dette implementeres hyppigt ved at afsætte (allokere) lagerplads til disse variable i en activation record eller stack frame oven på stakken (oven på den returadresse der er blevet lagt på stakken forinden). Derfor vil ethvert nyt kald føre til allokeringen af en ny activation record oven på en ny returadresse, og sammenblanding af variable undgås.
Selv om et programmeringssprog ikke giver muligheder for private/lokale variable (de oprindelige versioner af BASIC gjorde ikke dette), så kan man godt skrive rekursive programmer. Men det lægger en stor byrde på programmøren at holde rede på, hvilke data er gemt hvor.
Parameterlisten
Når man definerer en subrutine i et højniveausprog, vil man angive en række formelle parametre (evt. slet ingen). Disse formelle parametre vil blive benyttet i programkoden for subrutinen. Når man skriver et kald af subrutinen, vil man skulle skrive de aktuelle parametre, som skal benyttes i netop dette tilfælde. Det kan være variable eller konstanter/litteraler. Parametrene kan forstås på forskellige måder, hvor ikke alle er tilgængelige i hvert programmeringssprog og betegnelserne og implementeringen varierer.
Value. Parametrens værdi overføres til rutinen, men uanset hvad der måtte ske med denne værdi inden for subrutinen, så vil ændringerne ikke føres tilbage til den oprindelige variabel.
Value-result. Der overføres (typisk) en pointer til en variabel i det kaldende program. Hvis variablen ændres inden for subrutinen, vil ændringen ske i variablen i det kaldende program. Data kan føres ind, ændres, og den nye værdi føres ud.
Result. Endelig kan man have en parameter, der kun tillader et resultat at føres ud af subrutinen.
I en subrutine, der benyttes i et remote procedure call er det lidt mere kompliceret og kan give uventede resultater, hvid den samme variabel benyttes i to resultatparametre i samme kald.
Se også
Wheeler jump
Kilder og henvisninger
Programming Language Concepts and Paradigms, David A. Watt, 1990
Programming with Assembly Language, David E. Goldberg, Jacqueline A. Jones, Pat H. Sterbenz, 1988
Kildekode
Holisme | danish | 0.572643 |
Pony/builtin-AsioEvent-.txt |
AsioEvent¶
[Source]
Functions for asynchronous event notification.
primitive val AsioEvent
Constructors¶
create¶
[Source]
new val create()
: AsioEvent val^
Returns¶
AsioEvent val^
Public Functions¶
none¶
[Source]
An empty event.
fun box none()
: Pointer[AsioEvent val] tag
Returns¶
Pointer[AsioEvent val] tag
readable¶
[Source]
Returns true if the flags contain the readable flag.
fun box readable(
flags: U32 val)
: Bool val
Parameters¶
flags: U32 val
Returns¶
Bool val
writeable¶
[Source]
Returns true if the flags contain the writeable flag.
fun box writeable(
flags: U32 val)
: Bool val
Parameters¶
flags: U32 val
Returns¶
Bool val
disposable¶
[Source]
Returns true if the event should be disposed of.
fun box disposable(
flags: U32 val)
: Bool val
Parameters¶
flags: U32 val
Returns¶
Bool val
oneshotable¶
[Source]
Returns true if the flags contain the oneshot flag.
fun box oneshotable(
flags: U32 val)
: Bool val
Parameters¶
flags: U32 val
Returns¶
Bool val
dispose¶
[Source]
fun box dispose()
: U32 val
Returns¶
U32 val
read¶
[Source]
fun box read()
: U32 val
Returns¶
U32 val
write¶
[Source]
fun box write()
: U32 val
Returns¶
U32 val
timer¶
[Source]
fun box timer()
: U32 val
Returns¶
U32 val
signal¶
[Source]
fun box signal()
: U32 val
Returns¶
U32 val
read_write¶
[Source]
fun box read_write()
: U32 val
Returns¶
U32 val
oneshot¶
[Source]
fun box oneshot()
: U32 val
Returns¶
U32 val
read_write_oneshot¶
[Source]
fun box read_write_oneshot()
: U32 val
Returns¶
U32 val
eq¶
[Source]
fun box eq(
that: AsioEvent val)
: Bool val
Parameters¶
that: AsioEvent val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: AsioEvent val)
: Bool val
Parameters¶
that: AsioEvent val
Returns¶
Bool val
| pony | 2012304 | https://no.wikipedia.org/wiki/Miami%20Dolphins%20i%20NFL-sesongen%202022 | Miami Dolphins i NFL-sesongen 2022 | Miami Dolphins spilte i lagets 53. sesong i National Football League (NFL), 57. totalt, første under hovedtrener Mike McDaniel og syvende under general manager Chris Grier.
Dolphins nådde sluttspillet for første gang siden 2016 og sikret en tredje vinnende sesong på rad for første gang siden 2001–2003. Dolphins hadde sin beste sesongstart, på 8–3, siden 2001, men tapte deretter fem strake kamper. I sesongfinalen mot New York Jets vant Dolphins, og sikret en tangering av fjorårets sesongresultat samt en plass i sluttspillet. De endte seriespillet med samme sesongresultat som Pittsburgh Steelers, men vant tiebreakeren etter en seier over Steelers i uke 7. Dolphins møtte divisjonsrivalene Buffalo Bill i wildcardrunden, hvor de tapte 34–31.
Draft
Bytter
Personale ved sesongslutt
Spillerstall ved sesongslutt
Sesongoppkjøring
Seriespill
Terminliste
Note: Divisjonslag vises i fet tekst.
Kampreferater
Uke 1: mot New England Patriots
Uke 2: at Baltimore Ravens
Uke 3: mot Buffalo Bills
Uke 4: at Cincinnati Bengals
Uke 5: at New York Jets
Uke 6: mot Minnesota Vikings
Uke 7: mot Pittsburgh Steelers
Uke 8: at Detroit Lions
Uke 9: at Chicago Bears
Uke 10: mot Cleveland Browns
Uke 12: mot Houston Texans
{{Americanfootballbox
|titlestyle=;text-align:center;
|state=autocollapse
|title=Uke 12: Houston Texans at Miami Dolphins – Kampreferat
|date=27. november
|time=13:00 EST
|road=Texans
|R1=0|R2=0|R3=6|R4=9
|home=Dolphins
|H1=10|H2=20|H3=0|H4=0
|stadium=Hard Rock Stadium, Miami Gardens, Florida
|attendance=66 205
|weather= og delvis skyet
|referee=Jerome Boger
|TV=CBS
|TVAnnouncers=Spero Dedes, Jay Feely og Aditi Kinkhabwala
|reference=Oppsummering, Game Book
|scoring=
Første kvarter
MIA – Jason Sanders 45-yard field goal, 10:21. Dolphins 3–0. Drive: 9 plays, 39 yards, 3:01.
MIA – Durham Smythe 4-yard pasning fra Tua Tagovailoa (Jason Sanders spark), 2:57. Dolphins 10–0. Drive: 8 plays, 59 yards, 4:44.
Andre kvarter
MIA – Jeff Wilson 3-yard løp (Jason Sanders spark), 12:22. Dolphins 17–0. Drive: 1 play, 3 yards, 0:05.
MIA – Jason Sanders 23-yard field goal, 6:22. Dolphins 20–0. Drive: 10 plays, 72 yards, 4:32.
MIA – Xavien Howard 16-yard fumble return (Jason Sanders spark), 4:59. Dolphins 27–0.MIA – Jason Sanders 35-yard field goal, 0:00. Dolphins 30–0. Drive: 11 plays, 71 yards, 1:52.Tredje kvarterHOU – Dare Ogunbowale 3-yard løp (mislykket løp), 10:21. Dolphins 30–6. Drive: 6 plays, 64 yards, 3:10.Fjerde kvarterHOU – Jordan Akins 25-yard pasning fra Kyle Allen (mislykket pasning), 12:46. Dolphins 30–12. Drive: 6 plays, 50 yards, 2:25.
HOU – Ka'imi Fairbairn 28-yard field goal, 9:00. Dolphins 30–15. Drive: 8 plays, 57 yards, 2:47.
|stats=Beste passereHOU – Kyle Allen – 26/39, 215 yards, TD, 2 INT
MIA – Tua Tagovailoa – 22/36, 299 yards, TDBeste på løpHOU – Dare Ogunbowale – 4 løp, 14 yards, TD
MIA – Jeff Wilson – 13 løp, 39 yards, TDBeste mottakereHOU – Jordan Akins – 5 mottakelser, 61 yards, TD
MIA – Tyreek Hill – 6 mottakelser, 85 yards
}}
Uke 13: at San Francisco 49ers
Uke 14: at Los Angeles Chargers
Uke 15: at Buffalo Bills
Uke 16: mot Green Bay PackersJulekamp'''
Uke 17: at New England Patriots
Uke 18: mot New York Jets
Tabeller
Divisjon
Conference
Sluttspill
Terminliste
Kampreferater
AFC Wildcardrunden: at (2) Buffalo Bills
Priser og utmerkelser
Referanser
Eksterne lenker
National Football League-sesongen 2022 etter lag
2022
Sport i USA i 2022 | norwegian_bokmål | 1.095974 |
Pony/random-XorOshiro128StarStar-.txt |
XorOshiro128StarStar¶
[Source]
This is an implementation of xoroshiro128**, as detailed at:
http://xoshiro.di.unimi.it/
This Rand implementation is slightly slower than XorOshiro128Plus
but does not exhibit "mild dependencies in Hamming weights" (the lower four bits might fail linearity tests).
class ref XorOshiro128StarStar is
Random ref
Implements¶
Random ref
Constructors¶
from_u64¶
[Source]
Use seed x to seed a SplitMix64 and use this to
initialize the 128 bits of state.
new ref from_u64(
x: U64 val = 5489)
: XorOshiro128StarStar ref^
Parameters¶
x: U64 val = 5489
Returns¶
XorOshiro128StarStar ref^
create¶
[Source]
new ref create(
x: U64 val = 5489,
y: U64 val = 0)
: XorOshiro128StarStar ref^
Parameters¶
x: U64 val = 5489
y: U64 val = 0
Returns¶
XorOshiro128StarStar ref^
Public Functions¶
next¶
[Source]
fun ref next()
: U64 val
Returns¶
U64 val
has_next¶
[Source]
fun tag has_next()
: Bool val
Returns¶
Bool val
u8¶
[Source]
fun ref u8()
: U8 val
Returns¶
U8 val
u16¶
[Source]
fun ref u16()
: U16 val
Returns¶
U16 val
u32¶
[Source]
fun ref u32()
: U32 val
Returns¶
U32 val
u64¶
[Source]
fun ref u64()
: U64 val
Returns¶
U64 val
u128¶
[Source]
fun ref u128()
: U128 val
Returns¶
U128 val
ulong¶
[Source]
fun ref ulong()
: ULong val
Returns¶
ULong val
usize¶
[Source]
fun ref usize()
: USize val
Returns¶
USize val
i8¶
[Source]
fun ref i8()
: I8 val
Returns¶
I8 val
i16¶
[Source]
fun ref i16()
: I16 val
Returns¶
I16 val
i32¶
[Source]
fun ref i32()
: I32 val
Returns¶
I32 val
i64¶
[Source]
fun ref i64()
: I64 val
Returns¶
I64 val
i128¶
[Source]
fun ref i128()
: I128 val
Returns¶
I128 val
ilong¶
[Source]
fun ref ilong()
: ILong val
Returns¶
ILong val
isize¶
[Source]
fun ref isize()
: ISize val
Returns¶
ISize val
int_fp_mult[optional N: ((U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Real[N] val)]¶
[Source]
fun ref int_fp_mult[optional N: ((U8 val | U16 val | U32 val |
U64 val | U128 val | ULong val |
USize val) & Real[N] val)](
n: N)
: N
Parameters¶
n: N
Returns¶
N
int[optional N: ((U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Real[N] val)]¶
[Source]
fun ref int[optional N: ((U8 val | U16 val | U32 val |
U64 val | U128 val | ULong val |
USize val) & Real[N] val)](
n: N)
: N
Parameters¶
n: N
Returns¶
N
int_unbiased[optional N: ((U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Real[N] val)]¶
[Source]
fun ref int_unbiased[optional N: ((U8 val | U16 val | U32 val |
U64 val | U128 val | ULong val |
USize val) & Real[N] val)](
n: N)
: N
Parameters¶
n: N
Returns¶
N
real¶
[Source]
fun ref real()
: F64 val
Returns¶
F64 val
shuffle[A: A]¶
[Source]
fun ref shuffle[A: A](
array: Array[A] ref)
: None val
Parameters¶
array: Array[A] ref
Returns¶
None val
| pony | 443033 | https://sv.wikipedia.org/wiki/Gammal | Gammal | Se även ålderdom.
Gammal är ett runsvenskt mansnamn, som återfinns i flera svenska vikingatida runinskrifter, från främst Uppland (U 56, U 144, U 163, U 207, U 409, U 952, U 1070) , men också från Södermanland (Sö 359) och Öland (Öl 37), samt möjligen i en 1100-tals inskrift i Penningtons kyrka, Cumbria, England.
Det har använts ända till våra dagar, men är numera väldigt ovanligt.
Källor
Samnordisk runtextdatabas
Mansnamn | swedish | 1.045208 |
Pony/builtin-Pointer-.txt |
Pointer[A: A]¶
[Source]
A Pointer[A] is a raw memory pointer. It has no descriptor and thus can't be
included in a union or intersection, or be a subtype of any interface. Most
functions on a Pointer[A] are private to maintain memory safety.
struct ref Pointer[A: A]
Constructors¶
create¶
[Source]
A null pointer.
new ref create()
: Pointer[A] ref^
Returns¶
Pointer[A] ref^
Public Functions¶
offset¶
[Source]
Return a tag pointer to the n-th element.
fun tag offset(
n: USize val)
: Pointer[A] tag
Parameters¶
n: USize val
Returns¶
Pointer[A] tag
usize¶
[Source]
Convert the pointer into an integer.
fun tag usize()
: USize val
Returns¶
USize val
is_null¶
[Source]
Return true for a null pointer, false for anything else.
fun tag is_null()
: Bool val
Returns¶
Bool val
eq¶
[Source]
Return true if this address is that address.
fun tag eq(
that: Pointer[A] tag)
: Bool val
Parameters¶
that: Pointer[A] tag
Returns¶
Bool val
lt¶
[Source]
Return true if this address is less than that address.
fun tag lt(
that: Pointer[A] tag)
: Bool val
Parameters¶
that: Pointer[A] tag
Returns¶
Bool val
ne¶
[Source]
fun tag ne(
that: Pointer[A] tag)
: Bool val
Parameters¶
that: Pointer[A] tag
Returns¶
Bool val
le¶
[Source]
fun tag le(
that: Pointer[A] tag)
: Bool val
Parameters¶
that: Pointer[A] tag
Returns¶
Bool val
ge¶
[Source]
fun tag ge(
that: Pointer[A] tag)
: Bool val
Parameters¶
that: Pointer[A] tag
Returns¶
Bool val
gt¶
[Source]
fun tag gt(
that: Pointer[A] tag)
: Bool val
Parameters¶
that: Pointer[A] tag
Returns¶
Bool val
hash¶
[Source]
Returns a hash of the address.
fun tag hash()
: USize val
Returns¶
USize val
hash64¶
[Source]
Returns a 64-bit hash of the address.
fun tag hash64()
: U64 val
Returns¶
U64 val
| pony | 2881564 | https://sv.wikipedia.org/wiki/Athetis%20atripuncta | Athetis atripuncta | Athetis atripuncta är en fjärilsart som beskrevs av George Francis Hampson 1910. Athetis atripuncta ingår i släktet Athetis och familjen nattflyn. Inga underarter finns listade i Catalogue of Life.
Källor
Nattflyn
atripuncta | swedish | 1.32067 |
Pony/net-TCPListenAuth-.txt |
TCPListenAuth¶
[Source]
primitive val TCPListenAuth
Constructors¶
create¶
[Source]
new val create(
from: (AmbientAuth val | NetAuth val | TCPAuth val))
: TCPListenAuth val^
Parameters¶
from: (AmbientAuth val | NetAuth val | TCPAuth val)
Returns¶
TCPListenAuth val^
Public Functions¶
eq¶
[Source]
fun box eq(
that: TCPListenAuth val)
: Bool val
Parameters¶
that: TCPListenAuth val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: TCPListenAuth val)
: Bool val
Parameters¶
that: TCPListenAuth val
Returns¶
Bool val
| pony | 7419541 | https://sv.wikipedia.org/wiki/Ch%C4%81l%20%C5%A2arkh%C4%81n | Chāl Ţarkhān | Chāl Ţarkhān (persiska: چالِه طَرخان, چاه طَرخان, چال طرخان, Chāleh Ţarkhān) är en ort i Iran. Den ligger i provinsen Teheran, i den centrala delen av landet, km söder om huvudstaden Teheran. Chāl Ţarkhān ligger meter över havet och antalet invånare är .
Terrängen runt Chāl Ţarkhān är platt. Den högsta punkten i närheten är Kūh-e Torkaman, meter över havet, km nordost om Chāl Ţarkhān. Runt Chāl Ţarkhān är det tätbefolkat, med invånare per kvadratkilometer. Närmaste större samhälle är Qarchak, km sydost om Chāl Ţarkhān. Trakten runt Chāl Ţarkhān består till största delen av jordbruksmark.
Ett kallt stäppklimat råder i trakten. Årsmedeltemperaturen i trakten är °C. Den varmaste månaden är juli, då medeltemperaturen är °C, och den kallaste är januari, med °C. Genomsnittlig årsnederbörd är millimeter. Den regnigaste månaden är mars, med i genomsnitt mm nederbörd, och den torraste är september, med mm nederbörd.
Kommentarer
Källor
Orter i Teheran (provins) | swedish | 1.128196 |
Pony/random-Dice-.txt |
Dice¶
[Source]
A simple dice roller.
class ref Dice
Constructors¶
create¶
[Source]
Initialise with a random number generator.
new ref create(
from: Random ref)
: Dice ref^
Parameters¶
from: Random ref
Returns¶
Dice ref^
Public fields¶
var r: Random ref¶
[Source]
Public Functions¶
apply¶
[Source]
Return the sum of count rolls of a die with the given number of sides.
The die is numbered from 1 to sides. For example, count = 2 and
sides = 6 will return a value between 2 and 12.
fun ref apply(
count: U64 val,
sides: U64 val)
: U64 val
Parameters¶
count: U64 val
sides: U64 val
Returns¶
U64 val
| pony | 1711089 | https://no.wikipedia.org/wiki/Vitenskaps%C3%A5ret%201266 | Vitenskapsåret 1266 | Vitenskapsåret 1266 er en oversikt over hendelser, prisvinnere, fødte og avdøde personer med tilknytning til vitenskap i 1266.
Hendelser
Niccolò og Maffeo Polo nådde Kublai Khans hovedkvarter Khanbalik som nå er Beijing for første gang.
Fødsler
Dødsfall
Muʾayyad al-Dīn al-ʿUrḍī, arabisk matematiker og astronom.
Referanser | norwegian_bokmål | 1.298292 |
Pony/3_arithmetic.txt | # Arithmetic
Arithmetic is about the stuff you learn to do with numbers in primary school: Addition, Subtraction, Multiplication, Division and so on. Piece of cake. We all know that stuff. We nonetheless want to spend a whole section on this topic, because when it comes to computers the devil is in the details.
As introduced in [Primitives](/types/primitives.md#built-in-primitive-types) numeric types in Pony are represented as a special kind of primitive that maps to machine words. Both integer types and floating point types support a rich set of arithmetic and bit-level operations. These are expressed as [Infix Operators](/expressions/ops.md#infix-operators) that are implemented as plain functions on the numeric primitive types.
Pony focuses on two goals, performance and safety. From time to time, these two goals collide. This is true especially for arithmetic on integers and floating point numbers. Safe code should check for overflow, division by zero and other error conditions on each operation where it can happen. Pony tries to enforce as many safety invariants at compile time as it possibly can, but checks on arithmetic operations can only happen at runtime. Code focused on performance should execute integer arithmetic as fast and with as few CPU cycles as possible. Checking for overflow is expensive, doing plain dangerous arithmetic that is possibly subject to overflow is cheap.
Pony provides different ways of doing arithmetic to give programmers the freedom to chose which operation suits best for them, the safe but slower operation or the fast one, because performance is crucial for the use case.
## Integers
### Pony's default Integer Arithmetic
Doing arithmetic on integer types in Pony with the well known operators like `+`, `-`, `*`, `/` etc. tries to balance the needs for performance and correctness. All default arithmetic operations do not expose any undefined behaviour or error conditions. That means it handles both the cases for overflow/underflow and division by zero. Overflow/Underflow are handled with proper wrap around semantics, using one's complement on signed integers. In that respect we get behaviour like:
```pony
// unsigned wrap-around on overflow
U32.max_value() + 1 == 0
// signed wrap-around on overflow/underflow
I32.min_value() - 1 == I32.max_value()
```
In pony, the `+=`, `-=`, `*=` and `/=` is deprecated and users must explicitly write `i = i + 1` instead of `i += 1`.
Division by zero is a special case, which affects the division `/` and remainder `%` operators. In Mathematics, division by zero is undefined. In order to avoid either defining division as partial, throwing an error on division by zero or introducing undefined behaviour for that case, the _normal_ division is defined to be `0` when the divisor is `0`. This might lead to silent errors, when used without care. Choose [Partial and checked Arithmetic](#partial-and-checked-arithmetic) to detect division by zero.
In contrast to [Unsafe Arithmetic](#unsafe-integer-arithmetic) default arithmetic comes with a small runtime overhead because unlike the unsafe variants, it does detect and handle overflow and division by zero.
---
| Operator | Method | Description |
| -------- | ------ | --------------------------------------------- |
| `+` | `add()` | wrap around on over-/underflow |
| `-` | `sub()` | wrap around on over-/underflow |
| `*` | `mul()` | wrap around on over-/underflow |
| `/` | `div()` | `x / 0 = 0` |
| `%` | `rem()` | `x % 0 = 0` |
| `%%` | `mod()` | `x %% 0 = 0` |
| `-` | `neg()` | wrap around on over-/underflow |
| `>>` | `shr()` | filled with zeros, so `x >> 1 == x/2` is true |
| `<<` | `shl()` | filled with zeros, so `x << 1 == x*2` is true |
---
### Unsafe Integer Arithmetic
Unsafe integer arithmetic comes close to what you can expect from integer arithmetic in C. No checks, _raw speed_, possibilities of overflow, underflow or division by zero. Like in C, overflow, underflow and division by zero scenarios are undefined. Don't rely on the results in these cases. It could be anything and is highly platform specific. Division by zero might even crash your program with a `SIGFPE`. Our suggestion is to use these operators only if you can make sure you can exclude these cases.
Here is a list with all unsafe operations defined on Integers:
---
| Operator | Method | Undefined in case of |
| -------- | ------------ | ------------------------------------------------------------- |
| `+~` | `add_unsafe()` | Overflow E.g. `I32.max_value() +~ I32(1)` |
| `-~` | `sub_unsafe()` | Overflow |
| `*~` | `mul_unsafe()` | Overflow. |
| `/~` | `div_unsafe()` | Division by zero and overflow. E.g. `I32.min_value() / I32(-1)` |
| `%~` | `rem_unsafe()` | Division by zero and overflow. |
| `%%~` | `mod_unsafe()` | Division by zero and overflow. |
| `-~` | `neg_unsafe()` | Overflow. E.g. `-~I32.max_value()` |
| `>>~` | `shr_unsafe()` | If non-zero bits are shifted out. E.g. `I32(1) >>~ U32(2)` |
| `<<~` | `shl_unsafe()` | If bits differing from the final sign bit are shifted out. |
---
#### Unsafe Conversion
Converting between integer types in Pony needs to happen explicitly. Each numeric type can be converted explicitly into every other type.
```pony
// converting an I32 to a 32 bit floating point
I32(12).f32()
```
For each conversion operation there exists an unsafe counterpart, that is much faster when converting from and to floating point numbers. All these unsafe conversion between numeric types are undefined if the target type is smaller than the source type, e.g. if we convert from `I64` to `F32`.
```pony
// converting an I32 to a 32 bit floating point, the unsafe way
I32(12).f32_unsafe()
// an example for an undefined unsafe conversion
I64.max_value().f32_unsafe()
// an example for an undefined unsafe conversion, that is actually safe
I64(1).u8_unsafe()
```
Here is a full list of all available conversions for numeric types:
---
| Safe conversion | Unsafe conversion |
| --------------- | ----------------- |
| `u8()` | `u8_unsafe()` |
| `u16()` | `u16_unsafe()` |
| `u32()` | `u32_unsafe()` |
| `u64()` | `u64_unsafe()` |
| `u128()` | `u128_unsafe()` |
| `ulong()` | `ulong_unsafe()` |
| `usize()` | `usize_unsafe()` |
| `i8()` | `i8_unsafe()` |
| `i16()` | `i16_unsafe()` |
| `i32()` | `i32_unsafe()` |
| `i64()` | `i64_unsafe()` |
| `i128()` | `i128_unsafe()` |
| `ilong()` | `ilong_unsafe()` |
| `isize()` | `isize_unsafe()` |
| `f32()` | `f32_unsafe()` |
| `f64()` | `f64_unsafe()` |
---
### Partial and Checked Arithmetic
If overflow or division by zero are cases that need to be avoided and performance is no critical priority, partial or checked arithmetic offer great safety during runtime. Partial arithmetic operators error on overflow/underflow and division by zero. Checked arithmetic methods return a tuple of the result of the operation and a `Boolean` indicating overflow or other exceptional behaviour.
```pony
// partial arithmetic
let result =
try
USize.max_value() +? env.args.size()
else
env.out.print("overflow detected")
end
// checked arithmetic
let result =
match USize.max_value().addc(env.args.size())
| (let result: USize, false) =>
// use result
...
| (_, true) =>
env.out.print("overflow detected")
end
```
Partial as well as checked arithmetic comes with the burden of handling exceptions on every case and incurs some performance overhead, be warned.
| Partial Operator | Method | Description |
| ---------------- | ------------- | ------------------------------------------------- |
| `+?` | `add_partial()` | errors on overflow/underflow |
| `-?` | `sub_partial()` | errors on overflow/underflow |
| `*?` | `mul_partial()` | errors on overflow/underflow |
| `/?` | `div_partial()` | errors on overflow/underflow and division by zero |
| `%?` | `rem_partial()` | errors on overflow/underflow and division by zero |
| `%%?` | `mod_partial()` | errors on overflow/underflow and division by zero |
---
Checked arithmetic functions all return the result of the operation and a `Boolean` flag indicating overflow/underflow or division by zero in a tuple.
| Checked Method | Description |
| -------------- | ----------------------------------------------------------------------------------------- |
| `addc()` | Checked addition, second tuple element is `true` on overflow/underflow. |
| `subc()` | Checked subtraction, second tuple element is `true` on overflow/underflow. |
| `mulc()` | Checked multiplication, second tuple element is `true` on overflow. |
| `divc()` | Checked division, second tuple element is `true` on overflow or division by zero. |
| `remc()` | Checked remainder, second tuple element is `true` on overflow or division by zero. |
| `modc()` | Checked modulo, second tuple element is `true` on overflow or division by zero. |
| `fldc()` | Checked floored division, second tuple element is `true` on overflow or division by zero. |
---
## Floating Point
Pony default arithmetic on floating point numbers (`F32`, `F64`) behave as defined in the floating point standard IEEE 754.
That means e.g. that division by `+0` returns `Inf` and by `-0` returns `-Inf`.
### Unsafe Floating Point Arithmetic
Unsafe Floating Point operations do not necessarily comply with IEEE 754 for every input or every result. If any argument to an unsafe operation or its result are `+/-Inf` or `NaN`, the result is actually undefined.
This allows more aggressive optimizations and for faster execution, but only yields valid results for values different that the exceptional values `+/-Inf` and `NaN`. We suggest to only use unsafe arithmetic on floats if you can exclude those cases.
---
| Operator | Method |
| -------- | ------------ |
| `+~` | `add_unsafe()` |
| `-~` | `sub_unsafe()` |
| `*~` | `mul_unsafe()` |
| `/~` | `div_unsafe()` |
| `%~` | `rem_unsafe()` |
| `%%~` | `mod_unsafe()` |
| `-~` | `neg_unsafe()` |
| `<~` | `lt_unsafe()` |
| `>~` | `gt_unsafe()` |
| `<=~` | `le_unsafe()` |
| `>=~` | `ge_unsafe()` |
| `=~` | `eq_unsafe()` |
| `!=~` | `ne_unsafe()` |
---
Additionally `sqrt_unsafe()` is undefined for negative values.
| pony | 3828714 | https://sv.wikipedia.org/wiki/Placodes%20opacus | Placodes opacus | Placodes opacus är en skalbaggsart som beskrevs av Lewis 1900. Placodes opacus ingår i släktet Placodes och familjen stumpbaggar. Inga underarter finns listade i Catalogue of Life.
Källor
Stumpbaggar
opacus | swedish | 1.628776 |
Pony/src-itertools-iter-.txt |
iter.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046use "collections"
class Iter[A] is Iterator[A]
"""
Wrapper class containing methods to modify iterators.
"""
let _iter: Iterator[A]
new create(iter: Iterator[A]) =>
_iter = iter
fun ref has_next(): Bool =>
_iter.has_next()
fun ref next(): A ? =>
_iter.next()?
new maybe(value: (A | None)) =>
_iter =
object is Iterator[A]
var _value: (A | None) = consume value
fun has_next(): Bool => _value isnt None
fun ref next(): A ? => (_value = None) as A
end
new chain(outer_iterator: Iterator[Iterator[A]]) =>
"""
Take an iterator of iterators and return an Iter containing the
items of the first one, then the second one, and so on.
#### Example
```pony
let xs = [as I64: 1; 2].values()
let ys = [as I64: 3; 4].values()
Iter[I64].chain([xs; ys].values())
```
`1 2 3 4`
"""
_iter =
object
var inner_iterator: (Iterator[A] | None) = None
fun ref has_next(): Bool =>
if inner_iterator isnt None then
try
let iter = inner_iterator as Iterator[A]
if iter.has_next() then
return true
end
end
end
if outer_iterator.has_next() then
try
inner_iterator = outer_iterator.next()?
return has_next()
end
end
false
fun ref next(): A ? =>
if inner_iterator isnt None then
let iter = inner_iterator as Iterator[A]
if iter.has_next() then
return iter.next()?
end
end
if outer_iterator.has_next() then
inner_iterator = outer_iterator.next()?
return next()?
end
error
end
new repeat_value(value: A) =>
"""
Create an iterator that returns the given value forever.
#### Example
```pony
Iter[U32].repeat_value(7)
```
`7 7 7 7 7 7 7 7 7 ...`
"""
_iter =
object
let _v: A = consume value
fun ref has_next(): Bool => true
fun ref next(): A => _v
end
fun ref next_or(default: A): A =>
"""
Return the next value, or the given default.
#### Example
```pony
let x: (U64 | None) = 42
Iter[U64].maybe(x).next_or(0)
```
`42`
"""
if has_next() then
try next()? else default end
else
default
end
fun ref map_stateful[B](f: {ref(A!): B ?}): Iter[B]^ =>
"""
Allows stateful transformation of each element from the iterator, similar
to `map`.
"""
Iter[B](
object is Iterator[B]
fun ref has_next(): Bool =>
_iter.has_next()
fun ref next(): B ? =>
f(_iter.next()?)?
end)
fun ref filter_stateful(f: {ref(A!): Bool ?}): Iter[A!]^ =>
"""
Allows filtering of elements based on a stateful adapter, similar to
`filter`.
"""
Iter[A!](
object
var _next: (A! | _None) = _None
fun ref _find_next() =>
try
match _next
| _None =>
if _iter.has_next() then
let a = _iter.next()?
if try f(a)? else false end then
_next = a
else
_find_next()
end
end
end
end
fun ref has_next(): Bool =>
match _next
| _None =>
if _iter.has_next() then
_find_next()
has_next()
else
false
end
else
true
end
fun ref next(): A! ? =>
match _next = _None
| let a: A! => a
else
if _iter.has_next() then
_find_next()
next()?
else
error
end
end
end)
fun ref filter_map_stateful[B](f: {ref(A!): (B^ | None) ?}): Iter[B]^ =>
"""
Allows stateful modification to the stream of elements from an iterator,
similar to `filter_map`.
"""
Iter[B](
object is Iterator[B]
var _next: (B | _None) = _None
fun ref _find_next() =>
try
match _next
| _None =>
if _iter.has_next() then
match f(_iter.next()?)?
| let b: B => _next = consume b
| None => _find_next()
end
end
end
end
fun ref has_next(): Bool =>
match _next
| _None =>
if _iter.has_next() then
_find_next()
has_next()
else
false
end
else
true
end
fun ref next(): B ? =>
match _next = _None
| let b: B =>
consume b
else
if _iter.has_next() then
_find_next()
next()?
else
error
end
end
end)
fun ref all(f: {(A!): Bool ?} box): Bool =>
"""
Return false if at least one value of the iterator fails to match the
predicate `f`. This method short-circuits at the first value where the
predicate returns false, otherwise true is returned.
#### Examples
```pony
Iter[I64]([2; 4; 6].values())
.all({(x) => (x % 2) == 0 })
```
`true`
```pony
Iter[I64]([2; 3; 4].values())
.all({(x) => (x % 2) == 0 })
```
`false`
"""
for x in _iter do
if not (try f(x)? else false end) then
return false
end
end
true
fun ref any(f: {(A!): Bool ?} box): Bool =>
"""
Return true if at least one value of the iterator matches the predicate
`f`. This method short-circuits at the first value where the predicate
returns true, otherwise false is returned.
#### Examples
```pony
Iter[I64]([2; 4; 6].values())
.any({(I64) => (x % 2) == 1 })
```
`false`
```pony
Iter[I64]([2; 3; 4].values())
.any({(I64) => (x % 2) == 1 })
```
`true`
"""
for x in _iter do
if try f(x)? else false end then
return true
end
end
false
fun ref collect[B: Seq[A!] ref = Array[A!]](coll: B): B^ =>
"""
Push each value from the iterator into the collection `coll`.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.collect(Array[I64](3))
```
`[1, 2, 3]`
"""
for x in _iter do
coll.push(x)
end
coll
fun ref count(): USize =>
"""
Return the number of values in the iterator.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.count()
```
`3`
"""
var sum: USize = 0
for _ in _iter do
sum = sum + 1
end
sum
fun ref cycle(): Iter[A!]^ =>
"""
Repeatedly cycle through the values from the iterator.
WARNING: The values returned by the original iterator are cached, so
the input iterator should be finite.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.cycle()
```
`1 2 3 1 2 3 1 2 3 ...`
"""
let store = Array[A!]
Iter[A!](
object is Iterator[A!]
let _store: Array[A!] = store
var _store_iter: ArrayValues[A!, Array[A!]] = store.values()
var _first_time_through: Bool = true
fun ref has_next(): Bool => true
fun ref next(): A! ? =>
if _first_time_through then
if _iter.has_next() then
_store.push(_iter.next()?)
return _store(_store.size() - 1)?
end
_first_time_through = false
end
if not _store_iter.has_next() then
_store_iter.rewind()
end
_store_iter.next()?
end)
fun ref dedup[H: HashFunction[A] val = HashIs[A]](): Iter[A!]^ =>
"""
Return an iterator that removes duplicates from consecutive identical
elements. Equality is determined by the HashFunction `H`.
#### Example
```pony
Iter[USize]([as USize: 1; 1; 2; 3; 3; 2; 2].values())
.dedup()
```
`1 2 3 2`
"""
Iter[A!](
object is Iterator[A!]
var _prev_value: (A! | None) = None
var _prev_hash: USize = 0
fun ref has_next(): Bool =>
_iter.has_next()
fun ref next(): A! ? =>
let cur_value: A! = _iter.next()?
let cur_hash: USize = H.hash(cur_value)
match _prev_value
| let prev_value: A! =>
if (_prev_hash == cur_hash) and H.eq(prev_value, cur_value) then
this.next()?
else
_prev_value = cur_value
_prev_hash = cur_hash
cur_value
end
| None =>
_prev_value = cur_value
_prev_hash = cur_hash
cur_value
end
end)
fun ref enum[B: (Real[B] val & Number) = USize](): Iter[(B, A)]^ =>
"""
An iterator which yields the current iteration count as well as the next
value from the iterator.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.enum()
```
`(0, 1) (1, 2) (2, 3)`
"""
Iter[(B, A)](
object
var _i: B = 0
fun ref has_next(): Bool => _iter.has_next()
fun ref next(): (B, A) ? =>
(_i = _i + 1, _iter.next()?)
end)
fun ref filter(f: {(A!): Bool ?} box): Iter[A!]^ =>
"""
Return an iterator that only returns items that match the predicate `f`.
#### Example
```pony
Iter[I64]([1; 2; 3; 4; 5; 6].values())
.filter({(x) => (x % 2) == 0 })
```
`2 4 6`
"""
filter_stateful({(a: A!): Bool ? => f(a)? })
fun ref find(f: {(A!): Bool ?} box, n: USize = 1): A! ? =>
"""
Return the nth value in the iterator that satisfies the predicate `f`.
#### Examples
```pony
Iter[I64]([1; 2; 3].values())
.find({(x) => (x % 2) == 0 })
```
`2`
```pony
Iter[I64]([1; 2; 3; 4].values())
.find({(x) => (x % 2) == 0 }, 2)
```
`4`
"""
var c = n
for x in _iter do
if try f(x)? else false end then
if c == 1 then
return x
else
c = c - 1
end
end
end
error
fun ref filter_map[B](f: {(A!): (B^ | None) ?} box): Iter[B]^ =>
"""
Return an iterator which applies `f` to each element. If `None` is
returned, then the iterator will try again by applying `f` to the next
element. Otherwise, the value of type `B` is returned.
#### Example
```pony
Iter[I64]([as I64: 1; -2; 4; 7; -5])
.filter_map[USize](
{(i: I64): (USize | None) => if i >= 0 then i.usize() end })
```
`1 4 7`
```
"""
filter_map_stateful[B]({(a: A!): (B^ | None) ? => f(a) ? })
fun ref flat_map[B](f: {(A!): Iterator[B] ?} box): Iter[B]^ =>
"""
Return an iterator over the values of the iterators produced from the
application of the given function.
#### Example
```pony
Iter[String](["alpha"; "beta"; "gamma"])
.flat_map[U8]({(s: String): Iterator[U8] => s.values() })
```
`a l p h a b e t a g a m m a`
"""
Iter[B](
object is Iterator[B]
var _iterb: Iterator[B] =
try f(_iter.next()?)? else _EmptyIter[B] end
fun ref has_next(): Bool =>
if _iterb.has_next() then true
else
if _iter.has_next() then
try
_iterb = f(_iter.next()?)?
has_next()
else
false
end
else
false
end
end
fun ref next(): B ? =>
if _iterb.has_next() then
_iterb.next()?
else
_iterb = f(_iter.next()?)?
next()?
end
end)
fun ref fold[B](acc: B, f: {(B, A!): B^} box): B^ =>
"""
Apply a function to every element, producing an accumulated value.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.fold[I64](0, {(sum, x) => sum + x })
```
`6`
"""
var acc' = consume acc
for a in _iter do
acc' = f(consume acc', a)
end
acc'
fun ref fold_partial[B](acc: B, f: {(B, A!): B^ ?} box): B^ ? =>
"""
A partial version of `fold`.
"""
var acc' = consume acc
for a in _iter do
acc' = f(consume acc', a)?
end
acc'
fun ref interleave(other: Iterator[A]): Iter[A!] =>
"""
Return an iterator that alternates the values of the original iterator and
the other until both run out.
#### Example
```pony
Iter[USize](Range(0, 4))
.interleave(Range(4, 6))
```
`0 4 1 5 2 3`
"""
Iter[A!](
object is Iterator[A!]
var _use_original: Bool = true
fun ref has_next(): Bool =>
_iter.has_next() or other.has_next()
fun ref next(): A! ? =>
// Oscillate between iterators
if _use_original then
_use_original = not _use_original
// _iter might be empty, get next value from other
if _iter.has_next() then
_iter.next()?
else
other.next()?
end
else
_use_original = not _use_original
// other might be empty, get next value from _iter
if other.has_next() then
other.next()?
else
_iter.next()?
end
end
end)
fun ref interleave_shortest(other: Iterator[A]): Iter[A!] =>
"""
Return an iterator that alternates the values of the original iterator and
the other until one of them runs out.
#### Example
```pony
Iter[USize](Range(0, 4))
.interleave_shortest(Range(4, 6))
```
`0 4 1 5 2`
"""
Iter[A!](
object is Iterator[A!]
var _use_original: Bool = true
fun ref has_next(): Bool =>
if _use_original then
_iter.has_next()
else
other.has_next()
end
fun ref next(): A! ? =>
if this.has_next() then
if _use_original then
_use_original = not _use_original
_iter.next()?
else
_use_original = not _use_original
other.next()?
end
else
error
end
end)
fun ref intersperse(value: A, n: USize = 1): Iter[A!] =>
"""
Return an iterator that yields the value after every `n` elements of the
original iterator.
#### Example
```pony
Iter[USize](Range(0, 3))
.intersperse(8)
```
`0 8 1 8 2`
"""
Iter[A!](
object is Iterator[A!]
var _count: USize = 0
let _v: A = consume value
fun ref has_next(): Bool =>
_iter.has_next()
fun ref next(): A! ? =>
if (_count == n) then
_count = 0
_v
else
_count = _count + 1
_iter.next()?
end
end)
fun ref last(): A ? =>
"""
Return the last value of the iterator.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.last()
```
`3`
"""
while _iter.has_next() do _iter.next()?
else error
end
fun ref map[B](f: {(A!): B ?} box): Iter[B]^ =>
"""
Return an iterator where each item's value is the application of the given
function to the value in the original iterator.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.map[I64]({(x) => x * x })
```
`1 4 9`
"""
map_stateful[B]({(a: A!): B ? => f(a) ? })
fun ref nth(n: USize): A ? =>
"""
Return the nth value of the iterator.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.nth(2)
```
`2`
"""
var c = n
while _iter.has_next() and (c > 1) do
_iter.next()?
c = c - 1
end
if not _iter.has_next() then
error
else
_iter.next()?
end
fun ref run(on_error: {ref()} = {() => None } ref) =>
"""
Iterate through the values of the iterator without a for loop. The
function `on_error` will be called if the iterator's `has_next` method
returns true but its `next` method throws an error.
#### Example
```pony
Iter[I64]([1; 2; 3].values())
.map[None]({(x) => env.out.print(x.string()) })
.run()
```
```
1
2
3
```
"""
if not _iter.has_next() then return end
try
_iter.next()?
run(on_error)
else
on_error()
end
fun ref skip(n: USize): Iter[A]^ =>
"""
Skip the first n values of the iterator.
#### Example
```pony
Iter[I64]([1; 2; 3; 4; 5; 6].values())
.skip(3)
```
`4 5 6`
```pony
Iter[I64]([1; 2; 3].values())
.skip(3)
.has_next()
```
`false`
"""
var c = n
try
while _iter.has_next() and (c > 0) do
_iter.next()?
c = c - 1
end
end
this
fun ref skip_while(f: {(A!): Bool ?} box): Iter[A!]^ =>
"""
Skip values of the iterator while the predicate `f` returns true.
#### Example
```pony
Iter[I64]([1; 2; 3; 4; 5; 6].values())
.skip_while({(x) => x < 4 })
```
`4 5 6`
"""
filter_stateful(
object
var _done: Bool = false
fun ref apply(a: A!): Bool =>
if _done then return true end
if try f(a)? else false end then
false
else
_done = true
true
end
end)
fun ref step_by(n: USize = 1): Iter[A!] =>
"""
Return an iterator that yields every `n`th element of the
original iterator. n == 0 is treated like n == 1 rather than an error.
#### Example
```pony
Iter[USize](Range(0, 10))
.step_by(2)
```
`1 3 5 7 9`
"""
Iter[A!](
object is Iterator[A!]
let _step: USize = if n == 0 then 1 else n end
fun ref has_next(): Bool =>
_iter.has_next()
fun ref next(): A! ? =>
var steps_to_burn: USize = _step - 1
while steps_to_burn != 0 do
try _iter.next()? end
steps_to_burn = steps_to_burn - 1
end
_iter.next()?
end)
fun ref take(n: USize): Iter[A]^ =>
"""
Return an iterator for the first n elements.
#### Example
```pony
Iter[I64]([1; 2; 3; 4; 5; 6].values())
.take(3)
```
`1 2 3`
"""
Iter[A](
object
var _countdown: USize = n
fun ref has_next(): Bool =>
(_countdown > 0) and _iter.has_next()
fun ref next(): A ? =>
if _countdown > 0 then
_countdown = _countdown - 1
_iter.next()?
else
error
end
end)
fun ref take_while(f: {(A!): Bool ?} box): Iter[A!]^ =>
"""
Return an iterator that returns values while the predicate `f` returns
true. This iterator short-circuits the first time that `f` returns false or
raises an error.
#### Example
```pony
Iter[I64]([1; 2; 3; 4; 5; 6].values())
.take_while({(x) => x < 4 })
```
`1 2 3`
"""
Iter[A!](
object
var _done: Bool = false
var _next: (A! | None) = None
fun ref has_next(): Bool =>
if _next isnt None then true
else _try_next()
end
fun ref next(): A! ? =>
if (_next isnt None) or _try_next() then
(_next = None) as A!
else error
end
fun ref _try_next(): Bool =>
if _done then false
elseif not _iter.has_next() then
_done = true
false
else
_next =
try _iter.next()?
else
_done = true
return false
end
_done = try not f(_next as A!)? else true end
not _done
end
end)
fun ref unique[H: HashFunction[A] val = HashIs[A]](): Iter[A!]^ =>
"""
Return an iterator that filters out elements that have already been
produced. Uniqueness is determined by the HashFunction `H`.
#### Example
```pony
Iter[USize]([as USize: 1; 2; 1; 1; 3; 4; 1].values())
.unique()
```
`1 2 3 4`
"""
Iter[A!](
object
let _set: HashSet[A!, H] = HashSet[A!, H]()
fun ref has_next(): Bool =>
_iter.has_next()
fun ref next(): A! ? =>
let v = _iter.next()?
if _set.contains(v) then
next()?
else
_set.set(v)
v
end
end)
fun ref zip[B](i2: Iterator[B]): Iter[(A, B)]^ =>
"""
Zip two iterators together so that each call to next() results in
a tuple with the next value of the first iterator and the next value
of the second iterator. The number of items returned is the minimum of
the number of items returned by the two iterators.
#### Example
```pony
Iter[I64]([1; 2].values())
.zip[I64]([3; 4].values())
```
`(1, 3) (2, 4)`
"""
Iter[(A, B)](
object is Iterator[(A, B)]
let _i1: Iterator[A] = _iter
let _i2: Iterator[B] = i2
fun ref has_next(): Bool =>
_i1.has_next() and _i2.has_next()
fun ref next(): (A, B) ? =>
(_i1.next()?, _i2.next()?)
end)
fun ref zip2[B, C](i2: Iterator[B], i3: Iterator[C]): Iter[(A, B, C)]^ =>
"""
Zip three iterators together so that each call to next() results in
a tuple with the next value of the first iterator, the next value
of the second iterator, and the value of the third iterator. The
number of items returned is the minimum of the number of items
returned by the three iterators.
"""
Iter[(A, B, C)](
object is Iterator[(A, B, C)]
let _i1: Iterator[A] = _iter
let _i2: Iterator[B] = i2
let _i3: Iterator[C] = i3
fun ref has_next(): Bool =>
_i1.has_next() and _i2.has_next() and _i3.has_next()
fun ref next(): (A, B, C) ? =>
(_i1.next()?, _i2.next()?, _i3.next()?)
end)
fun ref zip3[B, C, D](i2: Iterator[B], i3: Iterator[C], i4: Iterator[D])
: Iter[(A, B, C, D)]^
=>
"""
Zip four iterators together so that each call to next() results in
a tuple with the next value of each of the iterators. The number of
items returned is the minimum of the number of items returned by the
iterators.
"""
Iter[(A, B, C, D)](
object is Iterator[(A, B, C, D)]
let _i1: Iterator[A] = _iter
let _i2: Iterator[B] = i2
let _i3: Iterator[C] = i3
let _i4: Iterator[D] = i4
fun ref has_next(): Bool =>
_i1.has_next()
and _i2.has_next()
and _i3.has_next()
and _i4.has_next()
fun ref next(): (A, B, C, D) ? =>
(_i1.next()?, _i2.next()?, _i3.next()?, _i4.next()?)
end)
fun ref zip4[B, C, D, E](
i2: Iterator[B],
i3: Iterator[C],
i4: Iterator[D],
i5: Iterator[E])
: Iter[(A, B, C, D, E)]^
=>
"""
Zip five iterators together so that each call to next() results in
a tuple with the next value of each of the iterators. The number of
items returned is the minimum of the number of items returned by the
iterators.
"""
Iter[(A, B, C, D, E)](
object is Iterator[(A, B, C, D, E)]
let _i1: Iterator[A] = _iter
let _i2: Iterator[B] = i2
let _i3: Iterator[C] = i3
let _i4: Iterator[D] = i4
let _i5: Iterator[E] = i5
fun ref has_next(): Bool =>
_i1.has_next()
and _i2.has_next()
and _i3.has_next()
and _i4.has_next()
and _i5.has_next()
fun ref next(): (A, B, C, D, E) ? =>
(_i1.next()?, _i2.next()?, _i3.next()?, _i4.next()?, _i5.next()?)
end)
primitive _None
class _EmptyIter[A]
fun ref has_next(): Bool => false
fun ref next(): A ? => error
| pony | 1927109 | https://sv.wikipedia.org/wiki/Villosa%20fabalis | Villosa fabalis | Villosa fabalis är en musselart som först beskrevs av I. Lea 1831. Villosa fabalis ingår i släktet Villosa och familjen målarmusslor. IUCN kategoriserar arten globalt som starkt hotad. Inga underarter finns listade i Catalogue of Life.
Källor
Målarmusslor
fabalis | swedish | 1.411471 |
Pony/pony_check-IntPairPropertySample-.txt |
IntPairPropertySample¶
[Source]
class ref IntPairPropertySample is
Stringable box
Implements¶
Stringable box
Constructors¶
create¶
[Source]
new ref create(
choice': U8 val,
int1': U128 val,
int2': U128 val)
: IntPairPropertySample ref^
Parameters¶
choice': U8 val
int1': U128 val
int2': U128 val
Returns¶
IntPairPropertySample ref^
Public fields¶
let choice: U8 val¶
[Source]
let int1: U128 val¶
[Source]
let int2: U128 val¶
[Source]
Public Functions¶
string¶
[Source]
fun box string()
: String iso^
Returns¶
String iso^
| pony | 2141995 | https://no.wikipedia.org/wiki/JCL | JCL | JCL, Job Control Language er et skriptspråk utviklet av IBM til jobbstyring. Språket er en del av operativsystemet MVS, og oppfølgerne OS/360 og z/OS på IBMs stormaskiner. Jobber i z/OS blir innledet av en serie instruksjoner skrevet i JCL. JCL styrer hvilke filer som skal allokeres til programmet, rekkefølgen i programeksekveringen, og håndteringen av uforutsette programavbrudd.
Utsagn
En JCL-jobb bruker tre hovedtyper av utsagn:
En JOBB som erklæring for å identifisere arbeidet enheten skal utføre;
En eller flere EXEC-setninger avhengig av antall jobbtrinn;
En eller flere DD-setninger for å identifisere inn- og ut-datasettene;
JCL bruker generiske filnavn, som består av SYSIN , SYSOUT og SYSPRINT. Når et program ber om data , får programmet dataene fra SYSIN . Når den produserer data , går dataene til SYSOUT , og trykte rapporter gå til SYSPRINT.
Eksempel på JCL-jobb
//T4395XXX JOBB (6158,TEST),'test',
// KLASSE=A,
// MSGLEVEL=(1,1),
// MSGCLASS=X,
// NOTIFY=&SYSUID
/*RUTEUTSKRIFT U920
//*---------------------------------------------
// JCLLIB ORDER=(CFDT.LxxxxPO.JCLLIB)
//*
//S01 EXEC PGM=IKJEFT01,DYNAMNBR=20
// INKLUDERE MEDLEM=USTEPLIB
//SYSPRINT DD SYSOUT=*
//SYSABOUT DD SYSOUT=*
//SYSDBOUT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//ABENDAID DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DBKT)
KJØR PROGRAM(B65XXXX),PLAN(CFXX0000)
ENN
/*
//
Referanser
Akronymer
Skriptspråk
IBM | norwegian_bokmål | 1.051475 |
Pony/src-pony_check-generator-.txt |
generator.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439use "collections"
use "assert"
use "itertools"
use "debug"
type ValueAndShrink[T1] is (T1^, Iterator[T1^])
"""
Possible return type for
[`Generator.generate`](pony_check-Generator.md#generate).
Represents a generated value and an Iterator of shrunken values.
"""
type GenerateResult[T2] is (T2^ | ValueAndShrink[T2])
"""
Return type for
[`Generator.generate`](pony_check-Generator.md#generate).
Either a single value or a Tuple of a value and an Iterator
of shrunken values based upon this value.
"""
class CountdownIter[T: (Int & Integer[T] val) = USize] is Iterator[T]
var _cur: T
let _to: T
new create(from: T, to: T = T.min_value()) =>
"""
Create am `Iterator` that counts down according to the specified arguments.
`from` is exclusive, `to` is inclusive.
"""
_cur = from
_to = to
fun ref has_next(): Bool =>
_cur > _to
fun ref next(): T =>
let res = _cur - 1
_cur = res
res
trait box GenObj[T]
fun generate(rnd: Randomness): GenerateResult[T] ?
fun shrink(t: T): ValueAndShrink[T] =>
(consume t, Poperator[T].empty())
fun generate_value(rnd: Randomness): T^ ? =>
"""
Simply generate a value and ignore any possible
shrink values.
"""
let g = this
match g.generate(rnd)?
| let t: T => consume t
| (let t: T, _) => consume t
end
fun generate_and_shrink(rnd: Randomness): ValueAndShrink[T] ? =>
"""
Generate a value and also return a shrink result,
even if the generator does not return any when calling `generate`.
"""
let g = this
match g.generate(rnd)?
| let t: T => g.shrink(consume t)
| (let t: T, let shrinks: Iterator[T^])=> (consume t, shrinks)
end
fun iter(rnd: Randomness): Iterator[GenerateResult[T]]^ =>
let that: GenObj[T] = this
object is Iterator[GenerateResult[T]]
fun ref has_next(): Bool => true
fun ref next(): GenerateResult[T] ? => that.generate(rnd)?
end
fun value_iter(rnd: Randomness): Iterator[T^] =>
let that: GenObj[T] = this
object is Iterator[T^]
fun ref has_next(): Bool => true
fun ref next(): T^ ? =>
match that.generate(rnd)?
| let value_only: T => consume value_only
| (let v: T, _) => consume v
end
end
fun value_and_shrink_iter(rnd: Randomness): Iterator[ValueAndShrink[T]] =>
let that: GenObj[T] = this
object is Iterator[ValueAndShrink[T]]
fun ref has_next(): Bool => true
fun ref next(): ValueAndShrink[T] ? =>
match that.generate(rnd)?
| let value_only: T => that.shrink(consume value_only)
| (let v: T, let shrinks: Iterator[T^]) => (consume v, consume shrinks)
end
end
class box Generator[T] is GenObj[T]
"""
A Generator is capable of generating random values of a certain type `T`
given a source of `Randomness`
and knows how to shrink or simplify values of that type.
When testing a property against one or more given Generators,
those generators' `generate` methods are being called many times
to generate sample values that are then used to validate the property.
When a failing sample is found, the PonyCheck engine is trying to find a
smaller or more simple sample by shrinking it with `shrink`.
If the generator did not provide any shrinked samples
as a result of `generate`, its `shrink` method is called
to obtain simpler results. PonyCheck obtains more shrunken samples until
the property is not failing anymore.
The last failing sample, which is considered the most simple one,
is then reported to the user.
"""
let _gen: GenObj[T]
new create(gen: GenObj[T]) =>
_gen = gen
fun generate(rnd: Randomness): GenerateResult[T] ? =>
"""
Let this generator generate a value
given a source of `Randomness`.
Also allow for returning a value and pre-generated shrink results
as a `ValueAndShrink[T]` instance, a tuple of `(T^, Seq[T])`.
This helps propagating shrink results through all kinds of Generator
combinators like `filter`, `map` and `flat_map`.
If implementing a custom `Generator` based on another one,
with a Generator Combinator, you should use shrunken values
returned by `generate` to also return shrunken values based on them.
If generating an example value is costly, it might be more efficient
to simply return the generated value and only shrink in big steps or do no
shrinking at all.
If generating values is lightweight, shrunken values should also be
returned.
"""
_gen.generate(rnd)?
fun shrink(t: T): ValueAndShrink[T] =>
"""
Simplify the given value.
As the returned value can also be `iso`, it needs to be consumed and
returned.
It is preferred to already return a `ValueAndShrink` from `generate`.
"""
_gen.shrink(consume t)
fun generate_value(rnd: Randomness): T^ ? =>
_gen.generate_value(rnd)?
fun generate_and_shrink(rnd: Randomness): ValueAndShrink[T] ? =>
_gen.generate_and_shrink(rnd)?
fun filter(predicate: {(T): (T^, Bool)} box): Generator[T] =>
"""
Apply `predicate` to the values generated by this Generator
and only yields values for which `predicate` returns `true`.
Example:
```pony
let even_i32s =
Generators.i32()
.filter(
{(t) => (t, ((t % 2) == 0)) })
```
"""
Generator[T](
object is GenObj[T]
fun generate(rnd: Randomness): GenerateResult[T] ? =>
(let t: T, let shrunken: Iterator[T^]) = _gen.generate_and_shrink(rnd)?
(let t1, let matches) = predicate(consume t)
if not matches then
generate(rnd)? // recurse, this might recurse infinitely
else
// filter the shrunken examples
(consume t1, _filter_shrunken(shrunken))
end
fun shrink(t: T): ValueAndShrink[T] =>
"""
shrink `t` using the generator this one filters upon
and call the filter predicate on the shrunken values
"""
(let s, let shrunken: Iterator[T^]) = _gen.shrink(consume t)
(consume s, _filter_shrunken(shrunken))
fun _filter_shrunken(shrunken: Iterator[T^]): Iterator[T^] =>
Iter[T^](shrunken)
.filter_map[T^]({
(t: T): (T^| None) =>
match predicate(consume t)
| (let matching: T, true) => consume matching
end
})
end)
fun map[U](fn: {(T): U^} box)
: Generator[U]
=>
"""
Apply `fn` to each value of this iterator
and yield the results.
Example:
```pony
let single_code_point_string_gen =
Generators.u32()
.map[String]({(u) => String.from_utf32(u) })
```
"""
Generator[U](
object is GenObj[U]
fun generate(rnd: Randomness): GenerateResult[U] ? =>
(let generated: T, let shrunken: Iterator[T^]) =
_gen.generate_and_shrink(rnd)?
(fn(consume generated), _map_shrunken(shrunken))
fun shrink(u: U): ValueAndShrink[U] =>
"""
We can only shrink if T is a subtype of U.
This method should in general not be called on this generator
as it is always returning shrinks with the call to `generate`
and they should be used for executing the shrink, but in case
a strange hierarchy of generators is used, which does not make use of
the pre-generated shrink results, we keep this method here.
"""
match u
| let ut: T =>
(let uts: T, let shrunken: Iterator[T^]) = _gen.shrink(consume ut)
(fn(consume uts), _map_shrunken(shrunken))
else
(consume u, Poperator[U].empty())
end
fun _map_shrunken(shrunken: Iterator[T^]): Iterator[U^] =>
Iter[T^](shrunken)
.map[U^]({(t) => fn(consume t) })
end)
fun flat_map[U](fn: {(T): Generator[U]} box): Generator[U] =>
"""
For each value of this generator, create a generator that is then combined.
"""
// TODO: enable proper shrinking:
Generator[U](
object is GenObj[U]
fun generate(rnd: Randomness): GenerateResult[U] ? =>
let value: T = _gen.generate_value(rnd)?
fn(consume value).generate_and_shrink(rnd)?
end)
fun union[U](other: Generator[U]): Generator[(T | U)] =>
"""
Create a generator that produces the value of this generator or the other
with the same probability, returning a union type of this generator and
the other one.
"""
Generator[(T | U)](
object is GenObj[(T | U)]
fun generate(rnd: Randomness): GenerateResult[(T | U)] ? =>
if rnd.bool() then
_gen.generate_and_shrink(rnd)?
else
other.generate_and_shrink(rnd)?
end
fun shrink(t: (T | U)): ValueAndShrink[(T | U)] =>
match consume t
| let tt: T => _gen.shrink(consume tt)
| let tu: U => other.shrink(consume tu)
end
end
)
type WeightedGenerator[T] is (USize, Generator[T] box)
"""
A generator with an associated weight, used in Generators.frequency.
"""
primitive Generators
"""
Convenience combinators and factories for common types and kind of Generators.
"""
fun unit[T](t: T, do_shrink: Bool = false): Generator[box->T] =>
"""
Generate a reference to the same value over and over again.
This reference will be of type `box->T` and not just `T`
as this generator will need to keep a reference to the given value.
"""
Generator[box->T](
object is GenObj[box->T]
let _t: T = consume t
fun generate(rnd: Randomness): GenerateResult[box->T] =>
if do_shrink then
(_t, Iter[box->T].repeat_value(_t))
else
_t
end
end)
fun none[T: None](): Generator[(T | None)] => Generators.unit[(T | None)](None)
fun repeatedly[T](f: {(): T^ ?} box): Generator[T] =>
"""
Generate values by calling the lambda `f` repeatedly,
once for every invocation of `generate`.
`f` needs to return an ephemeral type `T^`, that means
in most cases it needs to consume its returned value.
Otherwise we would end up with
an alias for `T` which is `T!`.
(e.g. `String iso` would be returned as `String iso!`,
which aliases as a `String tag`).
Example:
```pony
Generators.repeatedly[Writer]({(): Writer^ =>
let writer = Writer.>write("consume me, please")
consume writer
})
```
"""
Generator[T](
object is GenObj[T]
fun generate(rnd: Randomness): GenerateResult[T] ? =>
f()?
end)
fun seq_of[T, S: Seq[T] ref](
gen: Generator[T],
min: USize = 0,
max: USize = 100)
: Generator[S]
=>
"""
Create a `Seq` from the values of the given Generator with an optional
minimum and maximum size.
Defaults are 0 and 100, respectively.
"""
Generator[S](
object is GenObj[S]
let _gen: GenObj[T] = gen
fun generate(rnd: Randomness): GenerateResult[S] =>
let size = rnd.usize(min, max)
let result: S =
Iter[T^](_gen.value_iter(rnd))
.take(size)
.collect[S](S.create(size))
// create shrink_iter with smaller seqs and elements generated from _gen.value_iter
let shrink_iter =
Iter[USize](CountdownIter(size, min)) //Range(size, min, -1))
// .skip(1)
.map_stateful[S^]({
(s: USize): S^ =>
Iter[T^](_gen.value_iter(rnd))
.take(s)
.collect[S](S.create(s))
})
(consume result, shrink_iter)
end)
fun iso_seq_of[T: Any #send, S: Seq[T] iso](
gen: Generator[T],
min: USize = 0,
max: USize = 100)
: Generator[S]
=>
"""
Generate a `Seq[T]` where `T` must be sendable (i.e. it must have a
reference capability of either `tag`, `val`, or `iso`).
The constraint of the elements being sendable stems from the fact that
there is no other way to populate the iso seq if the elements might be
non-sendable (i.e. ref), as then the seq would leak references via
its elements.
"""
Generator[S](
object is GenObj[S]
let _gen: GenObj[T] = gen
fun generate(rnd: Randomness): GenerateResult[S] =>
let size = rnd.usize(min, max)
let result: S = recover iso S.create(size) end
let iter = _gen.value_iter(rnd)
var i = USize(0)
for elem in iter do
if i >= size then break end
result.push(consume elem)
i = i + 1
end
// create shrink_iter with smaller seqs and elements generated from _gen.value_iter
let shrink_iter =
Iter[USize](CountdownIter(size, min)) //Range(size, min, -1))
// .skip(1)
.map_stateful[S^]({
(s: USize): S^ =>
let res = recover iso S.create(s) end
let s_iter = _gen.value_iter(rnd)
var j = USize(0)
for s_elem in s_iter do
if j >= s then break end
res.push(consume s_elem)
j = j + 1
end
consume res
})
(consume result, shrink_iter)
end
)
fun array_of[T](
gen: Generator[T],
min: USize = 0,
max: USize = 100)
: Generator[Array[T]]
=>
Generators.seq_of[T, Array[T]](gen, min, max)
fun shuffled_array_gen[T](
gen: Generator[Array[T]])
: Generator[Array[T]]
=>
Generator[Array[T]](
object is GenObj[Array[T]]
let _gen: GenObj[Array[T]] = gen
fun generate(rnd: Randomness): GenerateResult[Array[T]] ? =>
(let arr, let source_shrink_iter) = _gen.generate_and_shrink(rnd)?
rnd.shuffle[T](arr)
let shrink_iter =
Iter[Array[T]](source_shrink_iter)
.map_stateful[Array[T]^]({
(shrink_arr: Array[T]): Array[T]^ =>
rnd.shuffle[T](shrink_arr)
consume shrink_arr
})
(consume arr, shrink_iter)
end
)
fun shuffled_iter[T](array: Array[T]): Generator[Iterator[this->T!]] =>
Generator[Iterator[this->T!]](
object is GenObj[Iterator[this->T!]]
fun generate(rnd: Randomness): GenerateResult[Iterator[this->T!]] =>
let cloned = array.clone()
rnd.shuffle[this->T!](cloned)
cloned.values()
end
)
fun list_of[T](
gen: Generator[T],
min: USize = 0,
max: USize = 100)
: Generator[List[T]]
=>
Generators.seq_of[T, List[T]](gen, min, max)
fun set_of[T: (Hashable #read & Equatable[T] #read)](
gen: Generator[T],
max: USize = 100)
: Generator[Set[T]]
=>
"""
Create a generator for `Set` filled with values
of the given generator `gen`.
The returned sets will have a size up to `max`,
but tend to have fewer than `max`
depending on the source generator `gen`.
E.g. if the given generator is for `U8` values and `max` is set to 1024,
the set will only ever be of size 256 max.
Also for efficiency purposes and to not loop forever,
this generator will only try to add at most `max` values to the set.
If there are duplicates, the set won't grow.
"""
Generator[Set[T]](
object is GenObj[Set[T]]
let _gen: GenObj[T] = gen
fun generate(rnd: Randomness): GenerateResult[Set[T]] =>
let size = rnd.usize(0, max)
let result: Set[T] =
Set[T].create(size).>union(
Iter[T^](_gen.value_iter(rnd))
.take(size)
)
let shrink_iter: Iterator[Set[T]^] =
Iter[USize](CountdownIter(size, 0)) // Range(size, 0, -1))
//.skip(1)
.map_stateful[Set[T]^]({
(s: USize): Set[T]^ =>
Set[T].create(s).>union(
Iter[T^](_gen.value_iter(rnd)).take(s)
)
})
(consume result, shrink_iter)
end)
fun set_is_of[T](
gen: Generator[T],
max: USize = 100)
: Generator[SetIs[T]]
=>
"""
Create a generator for `SetIs` filled with values
of the given generator `gen`.
The returned `SetIs` will have a size up to `max`,
but tend to have fewer entries
depending on the source generator `gen`.
E.g. if the given generator is for `U8` values and `max` is set to 1024
the set will only ever be of size 256 max.
Also for efficiency purposes and to not loop forever,
this generator will only try to add at most `max` values to the set.
If there are duplicates, the set won't grow.
"""
// TODO: how to remove code duplications
Generator[SetIs[T]](
object is GenObj[SetIs[T]]
fun generate(rnd: Randomness): GenerateResult[SetIs[T]] =>
let size = rnd.usize(0, max)
let result: SetIs[T] =
SetIs[T].create(size).>union(
Iter[T^](gen.value_iter(rnd))
.take(size)
)
let shrink_iter: Iterator[SetIs[T]^] =
Iter[USize](CountdownIter(size, 0)) //Range(size, 0, -1))
//.skip(1)
.map_stateful[SetIs[T]^]({
(s: USize): SetIs[T]^ =>
SetIs[T].create(s).>union(
Iter[T^](gen.value_iter(rnd)).take(s)
)
})
(consume result, shrink_iter)
end)
fun map_of[K: (Hashable #read & Equatable[K] #read), V](
gen: Generator[(K, V)],
max: USize = 100)
: Generator[Map[K, V]]
=>
"""
Create a generator for `Map` from a generator of key-value tuples.
The generated maps will have a size up to `max`,
but tend to have fewer entries depending on the source generator `gen`.
If the generator generates key-value pairs with
duplicate keys (based on structural equality),
the pair that is generated later will overwrite earlier entries in the map.
"""
Generator[Map[K, V]](
object is GenObj[Map[K, V]]
fun generate(rnd: Randomness): GenerateResult[Map[K, V]] =>
let size = rnd.usize(0, max)
let result: Map[K, V] =
Map[K, V].create(size).>concat(
Iter[(K^, V^)](gen.value_iter(rnd))
.take(size)
)
let shrink_iter: Iterator[Map[K, V]^] =
Iter[USize](CountdownIter(size, 0)) // Range(size, 0, -1))
// .skip(1)
.map_stateful[Map[K, V]^]({
(s: USize): Map[K, V]^ =>
Map[K, V].create(s).>concat(
Iter[(K^, V^)](gen.value_iter(rnd)).take(s)
)
})
(consume result, shrink_iter)
end)
fun map_is_of[K, V](
gen: Generator[(K, V)],
max: USize = 100)
: Generator[MapIs[K, V]]
=>
"""
Create a generator for `MapIs` from a generator of key-value tuples.
The generated maps will have a size up to `max`,
but tend to have fewer entries depending on the source generator `gen`.
If the generator generates key-value pairs with
duplicate keys (based on identity),
the pair that is generated later will overwrite earlier entries in the map.
"""
Generator[MapIs[K, V]](
object is GenObj[MapIs[K, V]]
fun generate(rnd: Randomness): GenerateResult[MapIs[K, V]] =>
let size = rnd.usize(0, max)
let result: MapIs[K, V] =
MapIs[K, V].create(size).>concat(
Iter[(K^, V^)](gen.value_iter(rnd))
.take(size)
)
let shrink_iter: Iterator[MapIs[K, V]^] =
Iter[USize](CountdownIter(size, 0)) //Range(size, 0, -1))
// .skip(1)
.map_stateful[MapIs[K, V]^]({
(s: USize): MapIs[K, V]^ =>
MapIs[K, V].create(s).>concat(
Iter[(K^, V^)](gen.value_iter(rnd)).take(s)
)
})
(consume result, shrink_iter)
end)
fun one_of[T](xs: ReadSeq[T], do_shrink: Bool = false): Generator[box->T] =>
"""
Generate a random value from the given ReadSeq.
This generator will generate nothing if the given xs is empty.
Generators created with this method do not support shrinking.
If `do_shrink` is set to `true`, it will return the same value
for each shrink round. Otherwise it will return nothing.
"""
Generator[box->T](
object is GenObj[box->T]
fun generate(rnd: Randomness): GenerateResult[box->T] ? =>
let idx = rnd.usize(0, xs.size() - 1)
let res = xs(idx)?
if do_shrink then
(res, Iter[box->T].repeat_value(res))
else
res
end
end)
fun one_of_safe[T](xs: ReadSeq[T], do_shrink: Bool = false): Generator[box->T] ? =>
"""
Version of `one_of` that will error if `xs` is empty.
"""
Fact(xs.size() > 0, "cannot use one_of_safe on empty ReadSeq")?
Generators.one_of[T](xs, do_shrink)
fun frequency[T](
weighted_generators: ReadSeq[WeightedGenerator[T]])
: Generator[T]
=>
"""
Choose a value of one of the given Generators,
while controlling the distribution with the associated weights.
The weights are of type `USize` and control how likely a value is chosen.
The likelihood of a value `v` to be chosen
is `weight_v` / `weights_sum`.
If all `weighted_generators` have equal size the distribution
will be uniform.
Example of a generator to output odd `U8` values
twice as likely as even ones:
```pony
Generators.frequency[U8]([
(1, Generators.u8().filter({(u) => (u, (u % 2) == 0 }))
(2, Generators.u8().filter({(u) => (u, (u % 2) != 0 }))
])
```
"""
// nasty hack to avoid handling the theoretical error case where we have
// no generator and thus would have to change the type signature
Generator[T](
object is GenObj[T]
fun generate(rnd: Randomness): GenerateResult[T] ? =>
let weight_sum: USize =
Iter[WeightedGenerator[T]](weighted_generators.values())
.fold[USize](
0,
// segfaults when types are removed - TODO: investigate
{(acc: USize, weighted_gen: WeightedGenerator[T]): USize^ =>
weighted_gen._1 + acc
})
let desired_sum = rnd.usize(0, weight_sum)
var running_sum: USize = 0
var chosen: (Generator[T] | None) = None
for weighted_gen in weighted_generators.values() do
let new_sum = running_sum + weighted_gen._1
if ((desired_sum == 0) or ((running_sum < desired_sum) and (desired_sum <= new_sum))) then
// we just crossed or reached the desired sum
chosen = weighted_gen._2
break
else
// update running sum
running_sum = new_sum
end
end
match chosen
| let x: Generator[T] box => x.generate(rnd)?
| None =>
Debug("chosen is None, desired_sum: " + desired_sum.string() +
"running_sum: " + running_sum.string())
error
end
end)
fun frequency_safe[T](
weighted_generators: ReadSeq[WeightedGenerator[T]])
: Generator[T] ?
=>
"""
Version of `frequency` that errors if the given `weighted_generators` is
empty.
"""
Fact(weighted_generators.size() > 0,
"cannot use frequency_safe on empty ReadSeq[WeightedGenerator]")?
Generators.frequency[T](weighted_generators)
fun zip2[T1, T2](
gen1: Generator[T1],
gen2: Generator[T2])
: Generator[(T1, T2)]
=>
"""
Zip two generators into a generator of a 2-tuple
containing the values generated by both generators.
"""
Generator[(T1, T2)](
object is GenObj[(T1, T2)]
fun generate(rnd: Randomness): GenerateResult[(T1, T2)] ? =>
(let v1: T1, let shrinks1: Iterator[T1^]) =
gen1.generate_and_shrink(rnd)?
(let v2: T2, let shrinks2: Iterator[T2^]) =
gen2.generate_and_shrink(rnd)?
((consume v1, consume v2), Iter[T1^](shrinks1).zip[T2^](shrinks2))
fun shrink(t: (T1, T2)): ValueAndShrink[(T1, T2)] =>
(let t1, let t2) = consume t
(let t11, let t1_shrunken: Iterator[T1^]) = gen1.shrink(consume t1)
(let t21, let t2_shrunken: Iterator[T2^]) = gen2.shrink(consume t2)
let shrunken = Iter[T1^](t1_shrunken).zip[T2^](t2_shrunken)
((consume t11, consume t21), shrunken)
end)
fun zip3[T1, T2, T3](
gen1: Generator[T1],
gen2: Generator[T2],
gen3: Generator[T3])
: Generator[(T1, T2, T3)]
=>
"""
Zip three generators into a generator of a 3-tuple
containing the values generated by those three generators.
"""
Generator[(T1, T2, T3)](
object is GenObj[(T1, T2, T3)]
fun generate(rnd: Randomness): GenerateResult[(T1, T2, T3)] ? =>
(let v1: T1, let shrinks1: Iterator[T1^]) =
gen1.generate_and_shrink(rnd)?
(let v2: T2, let shrinks2: Iterator[T2^]) =
gen2.generate_and_shrink(rnd)?
(let v3: T3, let shrinks3: Iterator[T3^]) =
gen3.generate_and_shrink(rnd)?
((consume v1, consume v2, consume v3),
Iter[T1^](shrinks1).zip2[T2^, T3^](shrinks2, shrinks3))
fun shrink(t: (T1, T2, T3)): ValueAndShrink[(T1, T2, T3)] =>
(let t1, let t2, let t3) = consume t
(let t11, let t1_shrunken: Iterator[T1^]) = gen1.shrink(consume t1)
(let t21, let t2_shrunken: Iterator[T2^]) = gen2.shrink(consume t2)
(let t31, let t3_shrunken: Iterator[T3^]) = gen3.shrink(consume t3)
let shrunken = Iter[T1^](t1_shrunken).zip2[T2^, T3^](t2_shrunken, t3_shrunken)
((consume t11, consume t21, consume t31), shrunken)
end)
fun zip4[T1, T2, T3, T4](
gen1: Generator[T1],
gen2: Generator[T2],
gen3: Generator[T3],
gen4: Generator[T4])
: Generator[(T1, T2, T3, T4)]
=>
"""
Zip four generators into a generator of a 4-tuple
containing the values generated by those four generators.
"""
Generator[(T1, T2, T3, T4)](
object is GenObj[(T1, T2, T3, T4)]
fun generate(rnd: Randomness): GenerateResult[(T1, T2, T3, T4)] ? =>
(let v1: T1, let shrinks1: Iterator[T1^]) =
gen1.generate_and_shrink(rnd)?
(let v2: T2, let shrinks2: Iterator[T2^]) =
gen2.generate_and_shrink(rnd)?
(let v3: T3, let shrinks3: Iterator[T3^]) =
gen3.generate_and_shrink(rnd)?
(let v4: T4, let shrinks4: Iterator[T4^]) =
gen4.generate_and_shrink(rnd)?
((consume v1, consume v2, consume v3, consume v4),
Iter[T1^](shrinks1).zip3[T2^, T3^, T4^](shrinks2, shrinks3, shrinks4))
fun shrink(t: (T1, T2, T3, T4)): ValueAndShrink[(T1, T2, T3, T4)] =>
(let t1, let t2, let t3, let t4) = consume t
(let t11, let t1_shrunken) = gen1.shrink(consume t1)
(let t21, let t2_shrunken) = gen2.shrink(consume t2)
(let t31, let t3_shrunken) = gen3.shrink(consume t3)
(let t41, let t4_shrunken) = gen4.shrink(consume t4)
let shrunken = Iter[T1^](t1_shrunken)
.zip3[T2^, T3^, T4^](t2_shrunken, t3_shrunken, t4_shrunken)
((consume t11, consume t21, consume t31, consume t41), shrunken)
end)
fun map2[T1, T2, T3](
gen1: Generator[T1],
gen2: Generator[T2],
fn: {(T1, T2): T3^})
: Generator[T3]
=>
"""
Convenience combinator for mapping 2 generators into 1.
"""
Generators.zip2[T1, T2](gen1, gen2)
.map[T3]({(arg) =>
(let arg1, let arg2) = consume arg
fn(consume arg1, consume arg2)
})
fun map3[T1, T2, T3, T4](
gen1: Generator[T1],
gen2: Generator[T2],
gen3: Generator[T3],
fn: {(T1, T2, T3): T4^})
: Generator[T4]
=>
"""
Convenience combinator for mapping 3 generators into 1.
"""
Generators.zip3[T1, T2, T3](gen1, gen2, gen3)
.map[T4]({(arg) =>
(let arg1, let arg2, let arg3) = consume arg
fn(consume arg1, consume arg2, consume arg3)
})
fun map4[T1, T2, T3, T4, T5](
gen1: Generator[T1],
gen2: Generator[T2],
gen3: Generator[T3],
gen4: Generator[T4],
fn: {(T1, T2, T3, T4): T5^})
: Generator[T5]
=>
"""
Convenience combinator for mapping 4 generators into 1.
"""
Generators.zip4[T1, T2, T3, T4](gen1, gen2, gen3, gen4)
.map[T5]({(arg) =>
(let arg1, let arg2, let arg3, let arg4) = consume arg
fn(consume arg1, consume arg2, consume arg3, consume arg4)
})
fun bool(): Generator[Bool] =>
"""
Create a generator of bool values.
"""
Generator[Bool](
object is GenObj[Bool]
fun generate(rnd: Randomness): Bool =>
rnd.bool()
end)
fun _int_shrink[T: (Int & Integer[T] val)](t: T^, min: T): ValueAndShrink[T] =>
"""
"""
let relation = t.compare(min)
let t_copy: T = T.create(t)
//Debug(t.string() + " is " + relation.string() + " than min " + min.string())
let sub_iter =
object is Iterator[T^]
var _cur: T = t_copy
var _subtract: F64 = 1.0
var _overflow: Bool = false
fun ref _next_minuend(): T =>
// f(x) = x + (2^-5 * x^2)
T.from[F64](_subtract = _subtract + (0.03125 * _subtract * _subtract))
fun ref has_next(): Bool =>
match relation
| Less => (_cur < min) and not _overflow
| Equal => false
| Greater => (_cur > min) and not _overflow
end
fun ref next(): T^ ? =>
match relation
| Less =>
let minuend: T = _next_minuend()
let old = _cur
_cur = _cur + minuend
if old > _cur then
_overflow = true
end
old
| Equal => error
| Greater =>
let minuend: T = _next_minuend()
let old = _cur
_cur = _cur - minuend
if old < _cur then
_overflow = true
end
old
end
end
let min_iter =
match relation
| let _: (Less | Greater) => Poperator[T]([min])
| Equal => Poperator[T].empty()
end
let shrunken_iter = Iter[T].chain(
[
Iter[T^](sub_iter).skip(1)
min_iter
].values())
(consume t, shrunken_iter)
fun u8(
min: U8 = U8.min_value(),
max: U8 = U8.max_value())
: Generator[U8]
=>
"""
Create a generator for U8 values.
"""
let that = this
Generator[U8](
object is GenObj[U8]
fun generate(rnd: Randomness): U8^ =>
rnd.u8(min, max)
fun shrink(u: U8): ValueAndShrink[U8] =>
that._int_shrink[U8](consume u, min)
end)
fun u16(
min: U16 = U16.min_value(),
max: U16 = U16.max_value())
: Generator[U16]
=>
"""
create a generator for U16 values
"""
let that = this
Generator[U16](
object is GenObj[U16]
fun generate(rnd: Randomness): U16^ =>
rnd.u16(min, max)
fun shrink(u: U16): ValueAndShrink[U16] =>
that._int_shrink[U16](consume u, min)
end)
fun u32(
min: U32 = U32.min_value(),
max: U32 = U32.max_value())
: Generator[U32]
=>
"""
Create a generator for U32 values.
"""
let that = this
Generator[U32](
object is GenObj[U32]
fun generate(rnd: Randomness): U32^ =>
rnd.u32(min, max)
fun shrink(u: U32): ValueAndShrink[U32] =>
that._int_shrink[U32](consume u, min)
end)
fun u64(
min: U64 = U64.min_value(),
max: U64 = U64.max_value())
: Generator[U64]
=>
"""
Create a generator for U64 values.
"""
let that = this
Generator[U64](
object is GenObj[U64]
fun generate(rnd: Randomness): U64^ =>
rnd.u64(min, max)
fun shrink(u: U64): ValueAndShrink[U64] =>
that._int_shrink[U64](consume u, min)
end)
fun u128(
min: U128 = U128.min_value(),
max: U128 = U128.max_value())
: Generator[U128]
=>
"""
Create a generator for U128 values.
"""
let that = this
Generator[U128](
object is GenObj[U128]
fun generate(rnd: Randomness): U128^ =>
rnd.u128(min, max)
fun shrink(u: U128): ValueAndShrink[U128] =>
that._int_shrink[U128](consume u, min)
end)
fun usize(
min: USize = USize.min_value(),
max: USize = USize.max_value())
: Generator[USize]
=>
"""
Create a generator for USize values.
"""
let that = this
Generator[USize](
object is GenObj[USize]
fun generate(rnd: Randomness): GenerateResult[USize] =>
rnd.usize(min, max)
fun shrink(u: USize): ValueAndShrink[USize] =>
that._int_shrink[USize](consume u, min)
end)
fun ulong(
min: ULong = ULong.min_value(),
max: ULong = ULong.max_value())
: Generator[ULong]
=>
"""
Create a generator for ULong values.
"""
let that = this
Generator[ULong](
object is GenObj[ULong]
fun generate(rnd: Randomness): ULong^ =>
rnd.ulong(min, max)
fun shrink(u: ULong): ValueAndShrink[ULong] =>
that._int_shrink[ULong](consume u, min)
end)
fun i8(
min: I8 = I8.min_value(),
max: I8 = I8.max_value())
: Generator[I8]
=>
"""
Create a generator for I8 values.
"""
let that = this
Generator[I8](
object is GenObj[I8]
fun generate(rnd: Randomness): I8^ =>
rnd.i8(min, max)
fun shrink(i: I8): ValueAndShrink[I8] =>
that._int_shrink[I8](consume i, min)
end)
fun i16(
min: I16 = I16.min_value(),
max: I16 = I16.max_value())
: Generator[I16]
=>
"""
Create a generator for I16 values.
"""
let that = this
Generator[I16](
object is GenObj[I16]
fun generate(rnd: Randomness): I16^ =>
rnd.i16(min, max)
fun shrink(i: I16): ValueAndShrink[I16] =>
that._int_shrink[I16](consume i, min)
end)
fun i32(
min: I32 = I32.min_value(),
max: I32 = I32.max_value())
: Generator[I32]
=>
"""
Create a generator for I32 values.
"""
let that = this
Generator[I32](
object is GenObj[I32]
fun generate(rnd: Randomness): I32^ =>
rnd.i32(min, max)
fun shrink(i: I32): ValueAndShrink[I32] =>
that._int_shrink[I32](consume i, min)
end)
fun i64(
min: I64 = I64.min_value(),
max: I64 = I64.max_value())
: Generator[I64]
=>
"""
Create a generator for I64 values.
"""
let that = this
Generator[I64](
object is GenObj[I64]
fun generate(rnd: Randomness): I64^ =>
rnd.i64(min, max)
fun shrink(i: I64): ValueAndShrink[I64] =>
that._int_shrink[I64](consume i, min)
end)
fun i128(
min: I128 = I128.min_value(),
max: I128 = I128.max_value())
: Generator[I128]
=>
"""
Create a generator for I128 values.
"""
let that = this
Generator[I128](
object is GenObj[I128]
fun generate(rnd: Randomness): I128^ =>
rnd.i128(min, max)
fun shrink(i: I128): ValueAndShrink[I128] =>
that._int_shrink[I128](consume i, min)
end)
fun ilong(
min: ILong = ILong.min_value(),
max: ILong = ILong.max_value())
: Generator[ILong]
=>
"""
Create a generator for ILong values.
"""
let that = this
Generator[ILong](
object is GenObj[ILong]
fun generate(rnd: Randomness): ILong^ =>
rnd.ilong(min, max)
fun shrink(i: ILong): ValueAndShrink[ILong] =>
that._int_shrink[ILong](consume i, min)
end)
fun isize(
min: ISize = ISize.min_value(),
max: ISize = ISize.max_value())
: Generator[ISize]
=>
"""
Create a generator for ISize values.
"""
let that = this
Generator[ISize](
object is GenObj[ISize]
fun generate(rnd: Randomness): ISize^ =>
rnd.isize(min, max)
fun shrink(i: ISize): ValueAndShrink[ISize] =>
that._int_shrink[ISize](consume i, min)
end)
fun byte_string(
gen: Generator[U8],
min: USize = 0,
max: USize = 100)
: Generator[String]
=>
"""
Create a generator for strings
generated from the bytes returned by the generator `gen`,
with a minimum length of `min` (default: 0)
and a maximum length of `max` (default: 100).
"""
Generator[String](
object is GenObj[String]
fun generate(rnd: Randomness): GenerateResult[String] =>
let size = rnd.usize(min, max)
let gen_iter = Iter[U8^](gen.value_iter(rnd))
.take(size)
let arr: Array[U8] iso = recover Array[U8](size) end
for b in gen_iter do
arr.push(b)
end
String.from_iso_array(consume arr)
fun shrink(s: String): ValueAndShrink[String] =>
"""
shrink string until `min` length.
"""
var str: String = s.trim(0, s.size()-1)
let shorten_iter: Iterator[String^] =
object is Iterator[String^]
fun ref has_next(): Bool => str.size() > min
fun ref next(): String^ =>
str = str.trim(0, str.size()-1)
end
let min_iter =
if s.size() > min then
Poperator[String]([s.trim(0, min)])
else
Poperator[String].empty()
end
let shrink_iter =
Iter[String^].chain([
shorten_iter
min_iter
].values())
(consume s, shrink_iter)
end)
fun ascii(
min: USize = 0,
max: USize = 100,
range: ASCIIRange = ASCIIAll)
: Generator[String]
=>
"""
Create a generator for strings withing the given `range`,
with a minimum length of `min` (default: 0)
and a maximum length of `max` (default: 100).
"""
let range_bytes = range.apply()
let fallback = U8(0)
let range_bytes_gen = usize(0, range_bytes.size()-1)
.map[U8]({(size) =>
try
range_bytes(size)?
else
// should never happen
fallback
end })
byte_string(range_bytes_gen, min, max)
fun ascii_printable(
min: USize = 0,
max: USize = 100)
: Generator[String]
=>
"""
Create a generator for strings of printable ASCII characters,
with a minimum length of `min` (default: 0)
and a maximum length of `max` (default: 100).
"""
ascii(min, max, ASCIIPrintable)
fun ascii_numeric(
min: USize = 0,
max: USize = 100)
: Generator[String]
=>
"""
Create a generator for strings of numeric ASCII characters,
with a minimum length of `min` (default: 0)
and a maximum length of `max` (default: 100).
"""
ascii(min, max, ASCIIDigits)
fun ascii_letters(
min: USize = 0,
max: USize = 100)
: Generator[String]
=>
"""
Create a generator for strings of ASCII letters,
with a minimum length of `min` (default: 0)
and a maximum length of `max` (default: 100).
"""
ascii(min, max, ASCIILetters)
fun utf32_codepoint_string(
gen: Generator[U32],
min: USize = 0,
max: USize = 100)
: Generator[String]
=>
"""
Create a generator for strings
from a generator of unicode codepoints,
with a minimum length of `min` codepoints (default: 0)
and a maximum length of `max` codepoints (default: 100).
Note that the byte length of the generated string can be up to 4 times
the size in code points.
"""
Generator[String](
object is GenObj[String]
fun generate(rnd: Randomness): GenerateResult[String] =>
let size = rnd.usize(min, max)
let gen_iter = Iter[U32^](gen.value_iter(rnd))
.filter({(cp) =>
// excluding surrogate pairs
(cp <= 0xD7FF) or (cp >= 0xE000) })
.take(size)
let s: String iso = recover String(size) end
for code_point in gen_iter do
s.push_utf32(code_point)
end
s
fun shrink(s: String): ValueAndShrink[String] =>
"""
Strip off codepoints from the end, not just bytes, so we
maintain a valid utf8 string.
Only shrink until given `min` is hit.
"""
var shrink_base = s
let s_len = s.codepoints()
let shrink_iter: Iterator[String^] =
if s_len > min then
Iter[String^].repeat_value(consume shrink_base)
.map_stateful[String^](
object
var len: USize = s_len - 1
fun ref apply(str: String): String =>
Generators._trim_codepoints(str, len = len - 1)
end
).take(s_len - min)
// take_while is buggy in pony < 0.21.0
//.take_while({(t) => t.codepoints() > min})
else
Poperator[String].empty()
end
(consume s, shrink_iter)
end)
fun _trim_codepoints(s: String, trim_to: USize): String =>
recover val
Iter[U32](s.runes())
.take(trim_to)
.fold[String ref](
String.create(trim_to),
{(acc, cp) => acc.>push_utf32(cp) })
end
fun unicode(
min: USize = 0,
max: USize = 100)
: Generator[String]
=>
"""
Create a generator for unicode strings,
with a minimum length of `min` codepoints (default: 0)
and a maximum length of `max` codepoints (default: 100).
Note that the byte length of the generated string can be up to 4 times
the size in code points.
"""
let range_1 = u32(0x0, 0xD7FF)
let range_1_size: USize = 0xD7FF
// excluding surrogate pairs
// this might be duplicate work but increases efficiency
let range_2 = u32(0xE000, 0x10FFFF)
let range_2_size = U32(0x10FFFF - 0xE000).usize()
let code_point_gen =
frequency[U32]([
(range_1_size, range_1)
(range_2_size, range_2)
])
utf32_codepoint_string(code_point_gen, min, max)
fun unicode_bmp(
min: USize = 0,
max: USize = 100)
: Generator[String]
=>
"""
Create a generator for unicode strings
from the basic multilingual plane only,
with a minimum length of `min` codepoints (default: 0)
and a maximum length of `max` codepoints (default: 100).
Note that the byte length of the generated string can be up to 4 times
the size in code points.
"""
let range_1 = u32(0x0, 0xD7FF)
let range_1_size: USize = 0xD7FF
// excluding surrogate pairs
// this might be duplicate work but increases efficiency
let range_2 = u32(0xE000, 0xFFFF)
let range_2_size = U32(0xFFFF - 0xE000).usize()
let code_point_gen =
frequency[U32]([
(range_1_size, range_1)
(range_2_size, range_2)
])
utf32_codepoint_string(code_point_gen, min, max)
| pony | 2567224 | https://sv.wikipedia.org/wiki/Procordulia%20lompobatang | Procordulia lompobatang | Procordulia lompobatang är en trollsländeart som beskrevs av Van Tol 1997. Procordulia lompobatang ingår i släktet Procordulia och familjen skimmertrollsländor. IUCN kategoriserar arten globalt som starkt hotad. Inga underarter finns listade i Catalogue of Life.
Källor
Skimmertrollsländor
lompobatang | swedish | 1.35945 |
Pony/collections-HashByteSeq-.txt |
HashByteSeq¶
[Source]
Hash and equality functions for arbitrary ByteSeq.
primitive val HashByteSeq is
HashFunction[(String box | Array[U8 val] box)] val,
HashFunction64[(String box | Array[U8 val] box)] val
Implements¶
HashFunction[(String box | Array[U8 val] box)] val
HashFunction64[(String box | Array[U8 val] box)] val
Constructors¶
create¶
[Source]
new val create()
: HashByteSeq val^
Returns¶
HashByteSeq val^
Public Functions¶
hash¶
[Source]
fun box hash(
x: (String box | Array[U8 val] box))
: USize val
Parameters¶
x: (String box | Array[U8 val] box)
Returns¶
USize val
hash64¶
[Source]
fun box hash64(
x: (String box | Array[U8 val] box))
: U64 val
Parameters¶
x: (String box | Array[U8 val] box)
Returns¶
U64 val
eq¶
[Source]
fun box eq(
x: (String box | Array[U8 val] box),
y: (String box | Array[U8 val] box))
: Bool val
Parameters¶
x: (String box | Array[U8 val] box)
y: (String box | Array[U8 val] box)
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: HashByteSeq val)
: Bool val
Parameters¶
that: HashByteSeq val
Returns¶
Bool val
| pony | 516524 | https://sv.wikipedia.org/wiki/BBCode | BBCode | BBCode, ibland BB-kod på svenska, är en förkortning som står för Bulletin Board Code och används som kodningsformat på en del internetforum. Konceptet liknar en simpel variant av HTML, men använder hakparenteser ([ ]) istället för "mindre- och större än"-tecken (< >). Urvalet taggar är också mycket mindre än det i HTML.
BBCode-taggar
Följande är de mest vanliga BBCode-taggar som finns tillgängliga på de flesta moderna forum. De visas nedan tillsammans med deras motsvarigheter i HTML-språk. Det ska dock noteras att taggarnas effekter kan bli ändrade automatiskt och att de inte fungerar likadant på alla webbplatser som använder BBCode.
Många forum har en FAQ med information om hur man kan använda deras egna varianter av BBCode.
Exempel på konvertering av BBCode till HTML med hjälp av PHP
<?php
function bbcode2html($strInput) {
return preg_replace(
array(
'/\\[url[\\:\\=]((\\"([\\W]*javascript\:[^\\"]*)?([^\\"]*)\\")|'.
'(([\\W]*javascript\:^\\*)?(^\\*)))\\]/ie', '/\\[\\/url\\]/i',
'/\\[b\\]/i', '/\\[\/b\\]/i',
'/\\[i\\]/i', '/\\[\/i\\]/i',
'/\\[quote\\]/i', '/\\[\/quote\\]/i'
),
array(
'\'<a href="\'.(\'$4\'?\'$4\':\'$7\').\'">\'', '</a>',
'<b>', '</b>',
'<i>', '</i>',
'<blockquote>', '</blockquote>'
),
$strInput
);
}
?>
Se även
Bulletin board system
Externa länkar
BBcode för PHP
Märkspråk | swedish | 1.012197 |
Pony/src-files-file_info-.txt |
file_info.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129use @pony_os_stat[Bool](path: Pointer[U8] tag, file: FileInfo tag)
use @pony_os_fstat[Bool](fd: I32, path: Pointer[U8] tag, file: FileInfo tag)
use @pony_os_fstatat[Bool](fd: I32, path: Pointer[U8] tag, file: FileInfo tag)
class val FileInfo
"""
This contains file system metadata for a path.
A symlink will report information about itself, other than the size which
will be the size of the target. A broken symlink will report as much as it
can and will set the broken flag.
"""
let filepath: FilePath
let mode: FileMode val = recover FileMode end
"""UNIX-style file mode."""
let hard_links: U32 = 0
"""Number of hardlinks to this `filepath`."""
let device: U64 = 0
"""
OS id of the device containing this `filepath`.
Device IDs consist of a major and minor device id,
denoting the type of device and the instance of this type on the system.
"""
let inode: U64 = 0
"""UNIX specific INODE number of `filepath`. Is 0 on Windows."""
let uid: U32 = 0
"""UNIX-style user ID of the owner of `filepath`."""
let gid: U32 = 0
"""UNIX-style user ID of the owning group of `filepath`."""
let size: USize = 0
"""
Total size of `filepath` in bytes.
In case of a symlink this is the size of the target, not the symlink itself.
"""
let access_time: (I64, I64) = (0, 0)
"""
Time of last access as a tuple of seconds and nanoseconds since the epoch:
```pony
(let a_secs: I64, let a_nanos: I64) = file_info.access_time
```
"""
let modified_time: (I64, I64) = (0, 0)
"""
Time of last modification as tuple of seconds and nanoseconds since the epoch:
```pony
(let m_secs: I64, let m_nanos: I64) = file_info.modified_time
```
"""
let change_time: (I64, I64) = (0, 0)
"""
Time of the last change either the attributes (number of links, owner,
group, file mode, ...) or the content of `filepath`
as a tuple of seconds and nanoseconds since the epoch:
```pony
(let c_secs: I64, let c_nanos: I64) = file_info.change_time
```
On Windows this will be the file creation time.
"""
let file: Bool = false
"""`true` if `filepath` points to an a regular file."""
let directory: Bool = false
"""`true` if `filepath` points to a directory."""
let pipe: Bool = false
"""`true` if `filepath` points to a named pipe."""
let symlink: Bool = false
"""`true` if `filepath` points to a symbolic link."""
let broken: Bool = false
"""`true` if `filepath` points to a broken symlink."""
new val create(from: FilePath) ? =>
"""
This will raise an error if the FileStat capability isn't available or the
path doesn't exist.
"""
if not from.caps(FileStat) then
error
end
filepath = from
if not @pony_os_stat(from.path.cstring(), this) then
error
end
new val _descriptor(fd: I32, path: FilePath) ? =>
"""
This will raise an error if the FileStat capability isn't available or the
file descriptor is invalid.
"""
if not path.caps(FileStat) or (fd == -1) then
error
end
filepath = path
let fstat =
@pony_os_fstat(fd, path.path.cstring(), this)
if not fstat then error end
new val _relative(fd: I32, path: FilePath, from: String) ? =>
if not path.caps(FileStat) or (fd == -1) then
error
end
filepath = path
let fstatat =
@pony_os_fstatat(fd, from.cstring(), this)
if not fstatat then error end
| pony | 1244333 | https://sv.wikipedia.org/wiki/Commodore%20DOS | Commodore DOS | Commodore DOS, alternativt CBM DOS, är operativsystemet för att hantera lagringsmedia på Commodores 8-bitars datorer under 1970-1990-talet. Till skillnad från andra DOS-system före och efter Commodore—vilka laddas från diskett och lagras i datorns RAM-minne vid systemstart, för att sedan exekveras—startade CBM DOS internt i diskettstationen eller hårddisken: operativsystemet är lagrat i ett (eller två) ROM-chip i den aktuella lagringsenheten, och sköttes av en eller fler dedikerade CPU:er (MOS 6502) som också var integrerade i den aktuella enheten.
CBM DOS-versioner
Åtminstone sju numrerade versioner av Commodore DOS är kända; följande lista ger information om versionnummer och aktuell lagringsenhet. Om inget annat nämns är diskettstationen 5¼". Markeringen "lp" står för "low profile". Diskettstationer vars modellnummer börjar med 15 använder sig av Commodores unika seriellprotokoll (TALK/LISTEN), alla andra av IEEE-488.
1.0 – hittas i diskettstationerna 2040 och 3040
2.0 – hittas i diskettstationerna 4040 och 3040
2.6 – hittas i diskettstationerna 1540, 1541, SX-64 (inbyggd), 1551, 2031 (+"lp"), samt 4031
2.7 – hittas i diskettstationerna 8050, 8250 (+"lp"), och SFD-1001
3.0 – hittas i diskettstationerna 1570, 1571, och 8280 (8280: 8"), samt i hårddiskarna 9060 och 9090
3.1 – hittas i den inbyggda diskettstationen 1571 i C128D/DCR
10.0 – hittas i diskettstationen 1581 (3½")
Version 2.6 var den absolut mest använda och kända DOS-versionen, då den användes i Commodore 1541 som sålde i stor mängd till den bästsäljande hemdatorn Commodore 64. Den blev även klonad av ett flertal tredjepartstillverkare.
Teknisk överblick
Katalogstruktur och filtyper
Disketterna kunde med CBM DOS innehålla upp till 144 filer (med undantag för 8050/8250 samt 1581). Filnamn kunde innehålla maximalt 16 tecken. Diskettens katalogstruktur skrevs på ett reserverat spår (18), vilket är mittspåret på en enkelsidig diskett med 35 spår. Det finns ingen möjlighet för underkataloger och filnamnen tvingades därför i teorin att vara unika (vilket innebär att om en fil med ett specifikt namn existerar så kan man inte skapa en fil med samma namn, och en fil kan heller inte döpas om till detta filnamn); emellertid kunde man, genom att skriva direkt till katalogstrukturens block, skapa flera filer med samma namn, även om detta försvårade eller gjorde det omöjligt att läsa filerna. Filer med samma namn har vanligen ingen funktion mer än att informera eller visuellt skapa ramar för filhanteringen. Ett populärt trick som användes av till exempel The Final Cartridge III var att skapa filer som döptes till "----------------" av typen DEL< i katalogstrukturen, och filer kunde då ordnas runt dessa linjer för att skapa filgrupperingar. Många spelutvecklare, warez-grupper och hackers ur demoscenen använde andra mer eller mindre utstuderade tekniker.
Det finns även en listig egendomlighet i filnamnen: filnamnen kan innehålla shift+space-tecken, och om en listad katalogstruktur visas i Commodore BASIC så kommer återstoden av filnamnet dyka upp efter filnamnet i kataloglistningen och BASIC kommer inte att anse det vara en del av filnamnet. Detta användes för att skapa saker som SAVE "PROGRAM(shift+space),8,1:",8,1 vilket dyker upp i katalogen som, exempelvis, 32 "PROGRAM",8,1: PRG. När användaren sedan flyttar pekaren till början av en rad i listningen och skriver LOAD, och därmed skriver över filstorleken på den linjen och trycker på ENTER, kommer BASIC att tolka detta som LOAD "PROGRAM",8,1: ..., och ignorera allt efter kolon.
En annan listighet är hur null byte kan skrivas i ett filnamn för att användas för att avbryta en listning efter att BASIC laddar denna. Om det finns tre null bytes så försvåras en listning i BASIC. Många maskinkodsprogrammerare kom att experimentera med null bytes i olika försök att hindra BASIC-programmerare att se och använda deras kod.
I BASIC så kan man få tillgång till katalogstrukturen som ett icke exekverbart BASIC-pseudoprogram med LOAD "$",8 följt av LIST. Den första raden har en meningslös radnumerering (0), och visar diskettens namn och ID samt en kort kod för vilken DOS-version som skapat katalogen (koderna skilde sig enbart om diskettformatet var inkompatibla, "2A" användes oftast för 5.25"-DOS-versioner, "3A" av 3.5"-1581). Raderna efter denna innehåller information om filstorlek (i block) samt filernas "pseudoradnummer", följt av filnamnet inom citationstecken och en treteckens kodtyp. De tre sista raderna visar antalet icke allokerade block på disketten (åter igen som ett "pseudoradnummer", följt av "BLOCKS FREE").
Intressant är även att om man på Commodore 64 skriver in LOAD "$",8,1 så fylls skärmen med "skräptecken" istället för att ladda in katalogen i BASIC RAM. Detta beror på att diskettstationen ger katalogen startadressen $0401 (1025), vilket motsvarar BASIC-start på Commodore PET, men korresponderar med skärmminnet på C64.
Om man listar katalogen med LOAD "$",8 så skriver man även över eventuella BASIC-program i RAM. DOS Wedge och ett antal andra tredjepartstillverkade insticksmoduler (cartridge) som Epyx FastLoad, Action Replay och The Final Cartridge III tillåter emellertid att man listar disketters innehåll utan risk för att radera ett aktuellt BASIC-program. Commodore 128 BASIC 7.0 inkluderar kommandona DIRECTORY och CATALOG, (kopplade till F3 vid start) som har samma funktion.
Följande filtyper är stödjs:
SEQ
Sekventiella filer är datafiler som kan läsas linjärt. Många ordbehandlare och andra Office-liknande program använder denna typ av filer för att spara data. En sekventiell fil är analog med en "flat file" i Linux eller UNIX, då den inte har någon speciell intern struktur.
PRG
Liknar SEQ-filer, men har en programheader bestående av de första två byten (en "little endian"-kodad 16-bitsadress). Alla maskinkodsprogram och BASIC-program sparas som PRG, och kan laddas till minnet med BASIC-kommandot LOAD (eller via KERNAL LOAD).
REL
Relativa filer är filer med fast bestämda storlekar. Till skillnad från andra filformat stödjer REL-filer äkta "random access" till valfri del av filen.
USR
Användardefinierade filer. Dessa liknar fysiskt sett SEQ-filer. De är tänkta att innehålla exekverbar kod för diskettstationens egen processor. Det är okänt om detta användes i någon utsträckning. Några program som använder ickestandardiserad lågnivåstruktur på diskett sparade data som USR, vilket kom att tolkas som en typ av markör för användaren: "låt bli mig, försök inte kopiera eller radera". GEOS' "VLIR-filer visas som USR-filer.
DEL
Icke dokumenterade internt använda filtyper. Liknar SEQ. CBM DOS kan inte skapa denna filtyp, utan den måste skapas genom direkt manipulering av filstruktur- och innehåll.
Det förekommer också filer med en asterisk (*) tillagd i katalogen (exempelvis *SEQ) vilket indikerar att filen inte stängdes efter att den skrevs. Oftast händer detta när ett program kraschar och lämnar en eller flera filer öppna på disketten. Om inte en manuellt tillagd CLOSE direkt körs i en fil som var öppen, kommer diskettens "block allocation map" (BAM) inte bli uppdaterad, vilket lämnar filsystemets struktur inkonsistent. *DEL är en speciell typ av filer som skrivs till filer som raderats; sådana filer syns inte i en kataloglistning, men går att rädda med hjälp av speciell mjukvara om inte annan data ännu skrivits över den.
En fil med asterisk kallas ofta för "splat", och kan normalt sett inte nås (men kan öppnas i ett "modify mode"). Försök att använda DOS-kommandot scratch för att radera en sådan fil kan ändra om i fillänkningen och därmed göra mer skada än nytta. Den enda praktiska metoden att radera en "splat"-fil är att öppna den i "modify mode" (och fixa filen), eller att validera disketten (se DOS-kommandot validate nedan).
Filer som följs av < (exempelvis PRG<) är låsta, och kan inte raderas. Det finns inga CMD DOS-kommandon för att sätta eller återställa detta, men många tredjepartsprogram skrevs för att göra detta möjligt. Dessa program läser vanligen katalogen genom kommandon för direkt åtkomst, gör nödvändiga ändringar i rådatan, och skriver tillbaka det hela till disketten igen.
Filåtkomst
Att komma åt filer är vanligen en uppgift för datorn. Datorns KERNAL ROM innehåller primitiva rutiner för att komma åt filer, och BASIC ROM innehåller support på en högre nivå för att nå filer genom BASIC-syntaxen. Den enda komponent som verkligen har med CMD DOS att göra är filnamnshantering med kommandona OPEN och LOAD/SAVE.
Att öppna en fil på en diskettstation eller hårddisk från Commodore innebär en del parametrar som är vagt analoga med filöppningsprocedurer i andra miljöer. Eftersom DOS faktiskt körs på en egen enhet, och inte datorn, måste filöppningssekvensen innehålla tillräckligt med information för att säkerställa en entydig tolkning. En typisk filöppningssekvens i BASIC lyder:
OPEN 3,8,4,"0:ADDRESSBOOK,S,W"
Referenser
Tryckta källor
Immers, Richard; Neufeld, Gerald G. (1984). Inside Commodore DOS. The Complete Guide to the 1541 Disk Operating System. DATAMOST, Inc & Reston Publishing Company, Inc. (Prentice-Hall). .
Englisch, Lothar; Szczepanowski, Norbert (1984). The Anatomy of the 1541 Disk Drive. Grand Rapids, MI: Abacus Software (translated from the original 1983 German edition, Düsseldorf: Data Becker GmbH). .
Lundahl, Reijo (1986). 1541-Levyasema. Amersoft.
Commodore 64
Operativsystem | swedish | 0.769042 |
Pony/format--index-.txt |
Format package¶
The Format package provides support for formatting strings. It can be
used to set things like width, padding and alignment, as well as
controlling the way numbers are displayed (decimal, octal,
hexadecimal).
Example program¶
use "format"
actor Main
fun disp(desc: String, v: I32, fmt: FormatInt = FormatDefault): String =>
Format(desc where width = 10)
+ ":"
+ Format.int[I32](v where width = 10, align = AlignRight, fmt = fmt)
new create(env: Env) =>
try
(let x, let y) = (env.args(1)?.i32()?, env.args(2)?.i32()?)
env.out.print(disp("x", x))
env.out.print(disp("y", y))
env.out.print(disp("hex(x)", x, FormatHex))
env.out.print(disp("hex(y)", y, FormatHex))
env.out.print(disp("x * y", x * y))
else
let exe = try env.args(0)? else "fmt_example" end
env.err.print("Usage: " + exe + " NUMBER1 NUMBER2")
end
Public Types¶
type Align
primitive AlignCenter
primitive AlignLeft
primitive AlignRight
primitive Format
primitive FormatBinary
primitive FormatBinaryBare
primitive FormatDefault
primitive FormatExp
primitive FormatExpLarge
primitive FormatFix
primitive FormatFixLarge
type FormatFloat
primitive FormatGeneral
primitive FormatGeneralLarge
primitive FormatHex
primitive FormatHexBare
primitive FormatHexSmall
primitive FormatHexSmallBare
type FormatInt
primitive FormatOctal
primitive FormatOctalBare
trait FormatSpec
primitive FormatUTF32
primitive PrefixDefault
type PrefixNumber
primitive PrefixSign
primitive PrefixSpace
trait PrefixSpec
| pony | 90539 | https://sv.wikipedia.org/wiki/Postscript%20Type%201 | Postscript Type 1 | Postscript Type 1 är ett fontformat som baserar sig på Postscript. Det blev det första vitt spridda formatet för skalbara typsnitt, det vill säga typsnitt som inte är låsta till vissa storlekar utan kan visas (renderas) i godtycklig storlek (typgrad). Varje teckenglyf beskrivs av den kontur som bildas när punkter binds samman med matematiska samband. Type 1-formatet var ett av de viktiga elementen i desktop publishing-revolutionen som påbörjades i mitten av 1980-talet, och har sedan dess haft en mycket stark ställning i den grafiska industrin.
För att snabba upp rastreringen av Postscript-koden har det gjorts en del begränsningar av vilka Postscript-konstruktioner som tillåts, och teckenglyferna kan endast byggas upp av slutna kubiska bézierkurvor. Rastrering av Type 1-typsnitt finns inbyggd i till exempel Windows 2000/XP och Mac OS, och kan för många andra operativsystem åstadkommas med Adobe Type Manager (ATM), som finns att ladda hem från Adobe i en begränsad Light-version.
Specifikationerna till Type 1-formatet var länge hemliga. I mars 1990 offentliggjordes de dock av Adobe, troligen som svar på Apples och Microsofts publicering av Truetype-formatet.
Multiple Master
En intressant utökning av Postscript är Multiple Master (MM), vilket innebär att ett typsnitt designas i några varianter (till exempel väldigt tunn och väldigt fet) och att övriga varianter däremellan kan interpoleras fram. Det går även att ha flera olika designaxlar; utöver exemplet med tjocklek kan till exempel storlek och bredd finnas som designaxlar. Alla kombinationer av ytterligheter måste formges separat, så ett typsnitt med tre designaxlar kräver åtta separat utformade varianter. Multiple Master bygger på samma idé som Knuth introducerade i slutet av 1970-talet med Metafont, men MM är kraftigt begränsat och inte lika flexibelt (men heller inte lika komplicerat för konstruktören).
Det finns i dag bara ett femtiotal typsnittfamiljer i MM-format, vilket dels beror på att stödet i programmen har varit dåligt, men även för att det är ekonomiskt mer lukrativt att sälja separata typsnitt. I oktober 1999 tillkännagav Adobe sin avsikt att avbryta utvecklingen av nya MM-typsnitt för att i stället koncentrera sig på Opentype. Ett populärt typsnitt som finns i en MM-version är Adobe Minion.
Se även
Postscript Type 3
Truetype
Metafont
Opentype
Externa länkar
Ladda hem Adobe Type Manager Light
Minion MM i Adobe Type Library
Typsnitt | swedish | 0.773575 |
Pony/pony_check-ASCIILetters-.txt |
ASCIILetters¶
[Source]
primitive val ASCIILetters
Constructors¶
create¶
[Source]
new val create()
: ASCIILetters val^
Returns¶
ASCIILetters val^
Public Functions¶
apply¶
[Source]
fun box apply()
: String val
Returns¶
String val
eq¶
[Source]
fun box eq(
that: ASCIILetters val)
: Bool val
Parameters¶
that: ASCIILetters val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: ASCIILetters val)
: Bool val
Parameters¶
that: ASCIILetters val
Returns¶
Bool val
| pony | 610902 | https://no.wikipedia.org/wiki/NASDAQ-100 | NASDAQ-100 | NASDAQ-100 er en aksjeindeks som inkluderer de 100 største innenlandske og internasjonale, ikke-finans-selskaper listet på NASDAQ-børsen, det er en modifisert market value-weighted index; indeksvekten er basert på selskapenes markedskapitalisering. Indeksen omfatter ikke finansselskaper, men omfatter selskaper utenfor USA; til forskjell fra S&P 500 og Dow Jones Industrial Average.
Selskaper i Nasdaq 100-indeksen
Liste per 20. januar 2009. Oppdatert liste på Eksterne lenker section.
Activision Blizzard (ATVI)
Adobe Systems Incorporated (ADBE)
Akamai Technologies, Inc. (AKAM)
Altera Corporation (ALTR)
Amazon.com, Inc. (AMZN)
Amgen Inc. (AMGN)
Apollo Group, Inc. (APOL)
Apple Inc. (AAPL)
Applied Materials, Inc. (AMAT)
Autodesk, Inc. (ADSK)
Automatic Data Processing, Inc. (ADP)
Baidu.com, Inc. (BIDU)
Bed Bath & Beyond Inc. (BBBY)
Biogen Idec Inc (BIIB)
Broadcom Corporation (BRCM)
C.H. Robinson Worldwide, Inc. (CHRW)
CA, Inc. (CA)
Celgene Corporation (CELG)
Cephalon, Inc. (CEPH)
Check Point Software Technologies Ltd. (CHKP)
Cintas Corporation (CTAS)
Cisco Systems, Inc. (CSCO)
Citrix Systems, Inc. (CTXS)
Cognizant Technology Solutions Corporation (CTSH)
Comcast Corporation (CMCSA)
Costco Wholesale Corporation (COST)
Dell Inc. (DELL)
DENTSPLY International Inc. (XRAY)
DISH Network Corporation (DISH)
eBay Inc. (EBAY)
Electronic Arts Inc. (ERTS)
Expedia, Inc. (EXPE)
Expeditors International of Washington, Inc. (EXPD)
Express Scripts, Inc. (ESRX)
Fastenal Company (FAST)
First Solar, Inc. (FSLR)
Fiserv, Inc. (FISV)
Flextronics International Ltd. (FLEX)
FLIR Systems, Inc. (FLIR)
Foster Wheeler Corporation (FWLT)
Garmin Ltd. (GRMN)
Genzyme Corporation (GENZ)
Gilead Sciences, Inc. (GILD)
Google Inc. (GOOG)
Hansen Natural Corporation (HANS)
Henry Schein, Inc. (HSIC)
Hologic, Inc. (HOLX)
IAC/InterActiveCorp (IACI)
Illumina, Inc. (ILMN)
Infosys Technologies (INFY)
Intel Corporation (INTC)
Intuit, Inc. (INTU)
Intuitive Surgical Inc. (ISRG)
J.B. Hunt Transport Services (JBHT)
Joy Global Inc. (JOYG)
Juniper Networks, Inc. (JNPR)
KLA-Tencor Corporation (KLAC)
Lam Research Corporation (LRCX)
Liberty Global, Inc. (LBTYA)
Liberty Media Corporation, Interactive Series A (LINTA)
Life Technologies Corporation (LIFE)
Linear Technology Corporation (LLTC)
Logitech International, SA (LOGI)
Marvell Technology Group, Ltd. (MRVL)
Maxim Integrated Products (MXIM)
Microchip Technology Incorporated (MCHP)
Microsoft Corporation (MSFT)
Millicom International Cellular S.A. (MICC)
NetApp, Inc. (NTAP)
News Corporation, Ltd. (NWSA)
NII Holdings, Inc. (NIHD)
NVIDIA Corporation (NVDA)
O'Reilly Automotive, Inc. (ORLY)
Oracle Corporation (ORCL)
PACCAR Inc. (PCAR)
Patterson Companies Inc. (PDCO)
Paychex, Inc. (PAYX)
Pharmaceutical Product Development, Inc. (PPDI)
QUALCOMM Incorporated (QCOM)
Research in Motion Limited (RIMM)
Ross Stores, Inc. (ROST)
Ryanair Holdings, PLC (RYAAY)
Seagate Technology Holdings (STX)
Sears Holdings Corporation (SHLD)
Sigma-Aldrich Corporation (SIAL)
Staples, Inc. (SPLS)
Starbucks Corporation (SBUX)
Steel Dynamics, Inc. (STLD)
Stericycle, Inc (SRCL)
Sun Microsystems, Inc. (JAVA)
Symantec Corporation (SYMC)
Teva Pharmaceutical Industries Limited (TEVA)
The DIRECTV Group, Inc. (DTV)
Urban Outfitters, Inc. (URBN)
VeriSign, Inc. (VRSN)
Vertex Pharmaceuticals (VRTX)
Warner Chilcott, Ltd. (WCRX)
Wynn Resorts, Ltd. (WYNN)
Xilinx, Inc. (XLNX)
Yahoo! Inc. (YHOO)
Se også
Nasdaq
Eksterne lenker
NASDAQ 100 Index
MarkedsIndekser
Aksjeindekser | norwegian_bokmål | 0.997249 |
Pony/src-pony_test-pony_test-.txt |
pony_test.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509"""
# PonyTest package
The PonyTest package provides a unit testing framework. It is designed to be as
simple as possible to use, both for the unit test writer and the user running
the tests.
To help simplify test writing and distribution this package depends on as few
other packages as possible. Currently the required packages are:
* builtin
* time
* collections
Each unit test is a class, with a single test function. By default all tests
run concurrently.
Each test run is provided with a helper object. This provides logging and
assertion functions. By default log messages are only shown for tests that
fail.
When any assertion function fails the test is counted as a fail. However, tests
can also indicate failure by raising an error in the test function.
## Example program
To use PonyTest simply write a class for each test and a TestList type that
tells the PonyTest object about the tests. Typically the TestList will be Main
for the package.
The following is a complete program with 2 trivial tests.
```pony
use "pony_test"
actor Main is TestList
new create(env: Env) =>
PonyTest(env, this)
new make() =>
None
fun tag tests(test: PonyTest) =>
test(_TestAdd)
test(_TestSub)
class iso _TestAdd is UnitTest
fun name():String => "addition"
fun apply(h: TestHelper) =>
h.assert_eq[U32](4, 2 + 2)
class iso _TestSub is UnitTest
fun name():String => "subtraction"
fun apply(h: TestHelper) =>
h.assert_eq[U32](2, 4 - 2)
```
The make() constructor is not needed for this example. However, it allows for
easy aggregation of tests (see below) so it is recommended that all test Mains
provide it.
Main.create() is called only for program invocations on the current package.
Main.make() is called during aggregation. If so desired extra code can be added
to either of these constructors to perform additional tasks.
## Test names
Tests are identified by names, which are used when printing test results and on
the command line to select which tests to run. These names are independent of
the names of the test classes in the Pony source code.
Arbitrary strings can be used for these names, but for large projects it is
strongly recommended to use a hierarchical naming scheme to make it easier to
select groups of tests.
You can skip any tests whose names start with a given string by using the
`--exclude=[prefix]` command line option.
You can run only tests whose names start with a given string by using the
`--only=[prefix]` command line option.
## Aggregation
Often it is desirable to run a collection of unit tests from multiple different
source files. For example, if several packages within a bundle each have their
own unit tests it may be useful to run all tests for the bundle together.
This can be achieved by writing an aggregate test list class, which calls the
list function for each package. The following is an example that aggregates the
tests from packages `foo` and `bar`.
```pony
use "pony_test"
use bar = "bar"
use foo = "foo"
actor Main is TestList
new create(env: Env) =>
PonyTest(env, this)
new make() =>
None
fun tag tests(test: PonyTest) =>
bar.Main.make().tests(test)
foo.Main.make().tests(test)
```
Aggregate test classes may themselves be aggregated. Every test list class may
contain any combination of its own tests and aggregated lists.
## Long tests
Simple tests run within a single function. When that function exits, either
returning or raising an error, the test is complete. This is not viable for
tests that need to use actors.
Long tests allow for delayed completion. Any test can call long_test() on its
TestHelper to indicate that it needs to keep running. When the test is finally
complete it calls complete() on its TestHelper.
The complete() function takes a Bool parameter to specify whether the test was
a success. If any asserts fail then the test will be considered a failure
regardless of the value of this parameter. However, complete() must still be
called.
Since failing tests may hang, a timeout must be specified for each long test.
When the test function exits a timer is started with the specified timeout. If
this timer fires before complete() is called the test is marked as a failure
and the timeout is reported.
On a timeout the timed_out() function is called on the unit test object. This
should perform whatever test specific tidy up is required to allow the program
to exit. There is no need to call complete() if a timeout occurs, although it
is not an error to do so.
Note that the timeout is only relevant when a test hangs and would otherwise
prevent the test program from completing. Setting a very long timeout on tests
that should not be able to hang is perfectly acceptable and will not make the
test take any longer if successful.
Timeouts should not be used as the standard method of detecting if a test has
failed.
## Exclusion groups
By default all tests are run concurrently. This may be a problem for some
tests, eg if they manipulate an external file or use a system resource. To fix
this issue any number of tests may be put into an exclusion group.
No tests that are in the same exclusion group will be run concurrently.
Exclusion groups are identified by name, arbitrary strings may be used.
Multiple exclusion groups may be used and tests in different groups may run
concurrently. Tests that do not specify an exclusion group may be run
concurrently with any other tests.
The command line option "--sequential" prevents any tests from running
concurrently, regardless of exclusion groups. This is intended for debugging
rather than standard use.
## Labels
Test can have label. Labels are used to filter which tests are run, by setting
command line argument `--label=[some custom label]`. It can be used to separate
unit tests from integration tests.
By default label is empty. You can set it up by overriding `label(): String`
method in unit test.
```pony
use "pony_test"
class iso _I8AddTest is UnitTest
fun name(): String => "_I8AddTest"
fun label(): String => "simple"
fun apply(h: TestHelper) =>
h.assert_eq[I8](1, 1)
```
## Setting up and tearing down a test environment
### Set Up
Any kind of fixture or environment necessary for executing a [UnitTest](pony_test-UnitTest.md)
can be set up either in the tests constructor or in a function called [set_up()](pony_test-UnitTest.md#set_up).
[set_up()](pony_test-UnitTest.md#set_up) is called before the test is executed. It is partial,
if it errors, the test is not executed but reported as failing during set up.
The test's [TestHelper](pony_test-TestHelper.md) is handed to [set_up()](pony_test-UnitTest.md#set_up)
in order to log messages or access the tests [Env](builtin-Env.md) via [TestHelper.env](pony_test-TestHelper.md#let-env-env-val).
### Tear Down
Each unit test object may define a [tear_down()](pony_test-UnitTest.md#tear_down) function. This is called after
the test has finished to allow tearing down of any complex environment that had
to be set up for the test.
The [tear_down()](pony_test-UnitTest.md#tear_down) function is called for each test regardless of whether it
passed or failed. If a test times out [tear_down()](pony_test-UnitTest.md#tear_down) will be called after
timed_out() returns.
When a test is in an exclusion group, the [tear_down()](pony_test-UnitTest.md#tear_down) call is considered part
of the tests run. The next test in the exclusion group will not start until
after [tear_down()](pony_test-UnitTest.md#tear_down) returns on the current test.
The test's [TestHelper](pony_test-TestHelper.md) is handed to [tear_down()](pony_test-UnitTest.md#tear_down) and it is permitted to log
messages and call assert functions during tear down.
### Example
The following example creates a temporary directory in the [set_up()](pony_test-UnitTest.md#set_up) function
and removes it in the [tear_down()](pony_test-UnitTest.md#tear_down) function, thus
simplifying the test function itself:
```pony
use "pony_test"
use "files"
class iso TempDirTest
var tmp_dir: (FilePath | None) = None
fun name(): String => "temp-dir"
fun ref set_up(h: TestHelper)? =>
tmp_dir = FilePath.mkdtemp(FileAuth(h.env.root), "temp-dir")?
fun ref tear_down(h: TestHelper) =>
try
(tmp_dir as FilePath).remove()
end
fun apply(h: TestHelper)? =>
let dir = tmp_dir as FilePath
// do something inside the temporary directory
```
"""
use "time"
use @ponyint_assert_disable_popups[None]()
actor PonyTest
"""
Main test framework actor that organises tests, collates information and
prints results.
"""
embed _groups: Array[(String, _Group)] = Array[(String, _Group)]
embed _records: Array[_TestRecord] = Array[_TestRecord]
let _env: Env
let _timers: Timers = Timers
var _do_nothing: Bool = false
var _verbose: Bool = false
var _sequential: Bool = false
var _no_prog: Bool = false
var _list_only: Bool = false
var _started: USize = 0
var _finished: USize = 0
var _any_found: Bool = false
var _all_started: Bool = false
// Filtering options
var _exclude: String = ""
var _label: String = ""
var _only: String = ""
new create(env: Env, list: TestList tag) =>
"""
Create a PonyTest object and use it to run the tests from the given
TestList
"""
_env = env
_process_opts()
_groups.push(("", _SimultaneousGroup))
@ponyint_assert_disable_popups()
list.tests(this)
_all_tests_applied()
be apply(test: UnitTest iso) =>
"""
Run the given test, subject to our filters and options.
"""
if _do_nothing then
return
end
var name = test.name()
// Ignore any tests that satisfy our "exclude" filter
if (_exclude != "") and name.at(_exclude, 0) then
return
end
// Ignore any tests that don't satisfy our "only" filter
if (_only != "") and (not name.at(_only, 0)) then
return
end
// Ignore tests when label arg is set and test label doesn't match
if (_label != "") and (_label != test.label()) then
return
end
_any_found = true
if _list_only then
// Don't actually run tests, just list them
_env.out.print(name)
return
end
var index = _records.size()
_records.push(_TestRecord(_env, name))
var group = _find_group(test.exclusion_group())
group(_TestRunner(this, index, consume test, group, _verbose, _env,
_timers))
fun ref _find_group(group_name: String): _Group =>
"""
Find the group to use for the given group name, subject to the
--sequential flag.
"""
var name = group_name
if _sequential then
// Use the same group for all tests.
name = "all"
end
for g in _groups.values() do
if g._1 == name then
return g._2
end
end
// Group doesn't exist yet, make it.
// We only need one simultaneous group, which we've already made. All new
// groups are exclusive.
let g = _ExclusiveGroup
_groups.push((name, g))
g
be _test_started(id: USize) =>
"""
A test has started running, update status info.
The id parameter is the test identifier handed out when we created the test
helper.
"""
_started = _started + 1
try
if not _no_prog then
_env.out.print(
_started.string() + " test" + _plural(_started)
+ " started, " + _finished.string() + " complete: "
+ _records(id)?.name + " started")
end
end
be _test_complete(id: USize, pass: Bool, log: Array[String] val) =>
"""
A test has completed, restore its result and update our status info.
The id parameter is the test identifier handed out when we created the test
helper.
"""
_finished = _finished + 1
try
_records(id)?._result(pass, log)
if not _no_prog then
_env.out.print(
_started.string() + " test" + _plural(_started)
+ " started, " + _finished.string() + " complete: "
+ _records(id)?.name + " complete")
end
end
if _all_started and (_finished == _records.size()) then
// All tests have completed
_print_report()
end
be _all_tests_applied() =>
"""
All our tests have been handed to apply(), setup for finishing
"""
if _do_nothing then
return
end
if not _any_found then
// No tests left after applying our filters
_env.out.print("No tests found")
return
end
if _list_only then
// No tests to run
return
end
_all_started = true
if _finished == _records.size() then
// All tests have completed
_print_report()
end
fun ref _process_opts() =>
"""
Process our command line options.
All command line arguments given must be recognised and make sense.
State for specified options is stored in object fields.
We don't use the options package because we aren't already dependencies.
"""
var exe_name = ""
for arg in _env.args.values() do
if exe_name == "" then
exe_name = arg
continue
end
if arg == "--sequential" then
_sequential = true
elseif arg == "--verbose" then
_verbose = true
elseif arg == "--noprog" then
_no_prog = true
elseif arg == "--list" then
_list_only = true
elseif arg.compare_sub("--exclude=", 10) is Equal then
_exclude = arg.substring(10)
elseif arg.compare_sub("--label=", 8) is Equal then
_label = arg.substring(8)
elseif arg.compare_sub("--only=", 7) is Equal then
_only = arg.substring(7)
else
_env.out.print("Unrecognised argument \"" + arg + "\"")
_env.out.print("")
_env.out.print("Usage:")
_env.out.print(" " + exe_name + " [options]")
_env.out.print("")
_env.out.print("Options:")
_env.out.print(" --exclude=prefix - Don't run tests whose names "
+ "start with the given prefix.")
_env.out.print(" --only=prefix - Only run tests whose names "
+ "start with the given prefix.")
_env.out.print(" --verbose - Show all test output.")
_env.out.print(" --sequential - Run tests sequentially.")
_env.out.print(" --noprog - Do not print progress messages.")
_env.out.print(" --list - List but do not run tests.")
_env.out.print(" --label=label - Only run tests with given label")
_do_nothing = true
return
end
end
fun _print_report() =>
"""
The tests are all complete, print out the results.
"""
var pass_count: USize = 0
var fail_count: USize = 0
// First we print the result summary for each test, in the order that they
// were given to us.
for rec in _records.values() do
if rec._report(_verbose) then
pass_count = pass_count + 1
else
fail_count = fail_count + 1
end
end
// Next we print the pass / fail stats.
_env.out.print("----")
_env.out.print("---- " + _records.size().string() + " test"
+ _plural(_records.size()) + " ran.")
_env.out.print(_Color.green() + "---- Passed: " + pass_count.string()
+ _Color.reset())
if fail_count == 0 then
// Success, nothing failed.
return
end
// Not everything passed.
_env.out.print(_Color.red() + "**** FAILED: " + fail_count.string()
+ " test" + _plural(fail_count) + ", listed below:" + _Color.reset())
// Finally print our list of failed tests.
for rec in _records.values() do
rec._list_failed()
end
_env.exitcode(-1)
fun _plural(n: USize): String =>
"""
Return a "s" or an empty string depending on whether the given number is 1.
For use when printing possibly plural words, eg "test" or "tests".
"""
if n == 1 then "" else "s" end
| pony | 311278 | https://sv.wikipedia.org/wiki/Watir | Watir | Watir är ett fritt verktyg för att automatisera tester av webbapplikationer och webbplatser. Watir är implementerat som en modul för programspråket Ruby och använder till exempel Internet Explorer på Windows för att simulera en användares surfande på webbplatsen. Det klickar på länkar, fyller i fält och skickar formulär för att sedan kontrollera texter och HTML i det resulterande svaret. Watir fungerar på Internet Explorer, Firefox, Mac och Linux, Safari på Mac samt Chrome på Windows.
Watir är en akronym för "Web Application Testing in Ruby". Det uttalas som engelskans water.
Externa länkar
Watirs officiella webbsida
Rubys officiella webbsida
Fri programvara och öppen källkod
Programmering | swedish | 1.324035 |
Pony/files-FileRemove-.txt |
FileRemove¶
[Source]
primitive val FileRemove
Constructors¶
create¶
[Source]
new val create()
: FileRemove val^
Returns¶
FileRemove val^
Public Functions¶
value¶
[Source]
fun box value()
: U32 val
Returns¶
U32 val
eq¶
[Source]
fun box eq(
that: FileRemove val)
: Bool val
Parameters¶
that: FileRemove val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FileRemove val)
: Bool val
Parameters¶
that: FileRemove val
Returns¶
Bool val
| pony | 107071 | https://da.wikipedia.org/wiki/Simsh%C3%B8vl | Simshøvl | Simshøvle er en type høvl, der udgør en broget mangfoldighed, og navnene på de forskellige typer er multiple: falssimshøvl, gesimshøvl, liggende, nærgående eller tætgående simshøvl, ma(h)l-, mophøvl, gnubber, morsehøvl, mushøvl eller musehøvl, der er en liggende og tætgående sidesimshøvl, endvidere smigsimshøvl, tilsimsningshøvl og næsehøvl, der har jernet siddende (næsten) helt fremme i tåen. De fleste profilhøvle er simshøvle, det samme en del smalle hulkelhøvle. Nedladningshøvl eller nedlægningshøvle er simshøvle. Kombihøvl, kanthøvl og nothøvl er det og gelændersnedkerens små gelænderhøvle, "gejsfushøvle". I visse tilfælde må vangehøvlen ligeledes regnes hertil.
Størrelse
Simshøvlen er normalt ret smal, bredde 16-40 mm. Det karakteristiske for typen er, at jernet for neden er jævnbredt med sålen, og oftest ender i en lang tunge der er kilet fast i stokken. På ældre eksemplarer ses jernet at være indsat fra siden, nærmest i en slags not, mens det på nyere er fæstnet i et udstemt hul midt i stokken; på denne måde svækkes vangerne ikke unødigt.
Da stokken på simshøvle af træ er så smal er der ikke plads til et egentligt spånhul, og spånerne må derfor ledes bort gennem et gennemgående hul umiddelbart over spunsen.
Andre former
Jernsimshøvle er gerne små handy stykker værktøj, først og fremmest i form af næsehøvle. Det er dem der oftest benævnes gnubbere (jf. Th. Topp, 1939) mus- eller morsehøvle. De fleste af dem er forsynet med hvad Topp kalder forstilling, et stykke jern der bøjer hen foran høvljernet og danner (stilbar) spunsåbning.
Der har gennem tiden været gjort mange bestræbelser på at udvikle tætgående typer, så snedkeren ikke behøvede at fjerne en dør mens han simsede karmen. Et af resultaterne er den liggende simshøvl, som i dens forskellige former bliver kaldt tilsimsningshøvl.
På nogen høvle med træstok ses en regulerbar spuns, der består af en bevægelig klods i forenden af sålen, fastgjort med en bolt og en fløjmøtrik.
Ekstern Henvisning
http://www.baskholm.dk/haandbog/haandbog.html
Træhøvle
Sløjd
Tømrerudtryk og snedkerudtryk | danish | 1.115515 |
Pony/collections-persistent--index-.txt |
Persistent Collections Package¶
List - A persistent list with functional transformations.
Map - A persistent map based on the Compressed Hash Array Mapped Prefix-tree
from 'Optimizing Hash-Array Mapped Tries for Fast and Lean Immutable JVM
Collections' by Michael J. Steindorfer and Jurgen J. Vinju.
Set - A persistent set implemented as a persistent map of an alias of a type
to itself.
Vec - A persistent vector based on the Hash Array Mapped Trie from 'Ideal Hash
Trees' by Phil Bagwell.
Public Types¶
class Cons
class HashMap
class HashSet
type List
primitive Lists
type Map
type MapIs
class MapKeys
class MapPairs
class MapValues
primitive Nil
type Set
type SetIs
class Vec
class VecKeys
class VecPairs
class VecValues
| pony | 2025687 | https://sv.wikipedia.org/wiki/Aphrocallistes%20yatsui | Aphrocallistes yatsui | Aphrocallistes yatsui är en svampdjursart som beskrevs av Okada 1932. Aphrocallistes yatsui ingår i släktet Aphrocallistes och familjen Aphrocallistidae.
Artens utbredningsområde är havet kring Japan. Inga underarter finns listade i Catalogue of Life.
Källor
Glassvampar
yatsui | swedish | 1.227788 |
Pony/collections-persistent-Vec-.txt |
Vec[A: Any #share]¶
[Source]
A persistent vector based on the Hash Array Mapped Trie from 'Ideal Hash
Trees' by Phil Bagwell.
class val Vec[A: Any #share]
Constructors¶
create¶
[Source]
new val create()
: Vec[A] val^
Returns¶
Vec[A] val^
Public Functions¶
size¶
[Source]
Return the amount of values in the vector.
fun box size()
: USize val
Returns¶
USize val
apply¶
[Source]
Get the i-th element, raising an error if the index is out of bounds.
fun box apply(
i: USize val)
: val->A ?
Parameters¶
i: USize val
Returns¶
val->A ?
update¶
[Source]
Return a vector with the i-th element changed, raising an error if the
index is out of bounds.
fun val update(
i: USize val,
value: val->A)
: Vec[A] val ?
Parameters¶
i: USize val
value: val->A
Returns¶
Vec[A] val ?
insert¶
[Source]
Return a vector with an element inserted. Elements after this are moved
up by one index, extending the vector. An out of bounds index raises an
error.
fun val insert(
i: USize val,
value: val->A)
: Vec[A] val ?
Parameters¶
i: USize val
value: val->A
Returns¶
Vec[A] val ?
delete¶
[Source]
Return a vector with an element deleted. Elements after this are moved
down by one index, compacting the vector. An out of bounds index raises an
error.
fun val delete(
i: USize val)
: Vec[A] val ?
Parameters¶
i: USize val
Returns¶
Vec[A] val ?
remove¶
[Source]
Return a vector with n elements removed, beginning at index i.
fun val remove(
i: USize val,
n: USize val)
: Vec[A] val ?
Parameters¶
i: USize val
n: USize val
Returns¶
Vec[A] val ?
push¶
[Source]
Return a vector with the value added to the end.
fun val push(
value: val->A)
: Vec[A] val
Parameters¶
value: val->A
Returns¶
Vec[A] val
pop¶
[Source]
Return a vector with the value at the end removed.
fun val pop()
: Vec[A] val ?
Returns¶
Vec[A] val ?
concat¶
[Source]
Return a vector with the values of the given iterator added to the end.
fun val concat(
iter: Iterator[val->A] ref)
: Vec[A] val
Parameters¶
iter: Iterator[val->A] ref
Returns¶
Vec[A] val
find¶
[Source]
Find the nth appearance of value from the beginning of the vector,
starting at offset and examining higher indices, and using the
supplied predicate for comparisons. Returns the index of the value, or
raise an error if the value isn't present.
By default, the search starts at the first element of the vector,
returns the first instance of value found, and uses object identity
for comparison.
fun val find(
value: val->A,
offset: USize val = 0,
nth: USize val = 0,
predicate: {(A, A): Bool}[A] val = lambda)
: USize val ?
Parameters¶
value: val->A
offset: USize val = 0
nth: USize val = 0
predicate: {(A, A): Bool}[A] val = lambda
Returns¶
USize val ?
contains¶
[Source]
Returns true if the vector contains value, false otherwise.
fun val contains(
value: val->A,
predicate: {(A, A): Bool}[A] val = lambda)
: Bool val
Parameters¶
value: val->A
predicate: {(A, A): Bool}[A] val = lambda
Returns¶
Bool val
slice¶
[Source]
Return a vector that is a clone of a portion of this vector. The range is
exclusive and saturated.
fun val slice(
from: USize val = 0,
to: USize val = call,
step: USize val = 1)
: Vec[A] val
Parameters¶
from: USize val = 0
to: USize val = call
step: USize val = 1
Returns¶
Vec[A] val
reverse¶
[Source]
Return a vector with the elements in reverse order.
fun val reverse()
: Vec[A] val
Returns¶
Vec[A] val
keys¶
[Source]
Return an iterator over the indices in the vector.
fun val keys()
: VecKeys[A] ref^
Returns¶
VecKeys[A] ref^
values¶
[Source]
Return an iterator over the values in the vector.
fun val values()
: VecValues[A] ref^
Returns¶
VecValues[A] ref^
pairs¶
[Source]
Return an iterator over the (index, value) pairs in the vector.
fun val pairs()
: VecPairs[A] ref^
Returns¶
VecPairs[A] ref^
| pony | 1219468 | https://sv.wikipedia.org/wiki/Dualbas | Dualbas | En dualbas är ett begrepp inom linjär algebra som syftar på en speciell bas i ett vektorrums dualrum, givet en bas i det ursprungliga vektorrummet.
Definition
Givet ett ändligtdimensionellt vektorrum V och en bas till V bestående av element (ei), konstrueras en dualbas bestående av element (fi) i dualrummet V* genom:
Linjäriteten hos funktionalerna fi gör att detta definierar fi:s värde för alla vektorer i V. Andra notationer för fi är ei* och ei.
Om V är ett ändligtdimensionellt vektorrum är dualbasen en bas för dualrummet. Är V oändligtdimensionellt är detta inte garanterat.
Exempel
Komplexa tal
Om man betraktar de komplexa talen som vektorrum över de reella talen och väljer basvektorerna 1 och i blir dualbasen Re och Im, de funktioner som avbildar ett komplext tal på dess real- respektive imaginärdel.
Polynomrum
Låt V vara vektorrummet bestående av polynom med grad mindre än eller lika med 2, dvs polynom på formen ax2 + bx + c. Ta {1, x, x2} som bas för V. Vi får då dualbasen {f1, f2, f3}:
Dualbasvektorerna kan tolkas som:
.
Referenser
Se även
Reflexivt rum
Linjär algebra | swedish | 0.854358 |
Pony/src-buffered-writer-.txt |
writer.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296class Writer
"""
A buffer for building messages.
`Writer` provides an way to create byte sequences using common
data encodings. The `Writer` manages the underlying arrays and
sizes. It is useful for encoding data to send over a network or
store in a file. Once a message has been built you can call `done()`
to get the message's `ByteSeq`s, and you can then reuse the
`Writer` for creating a new message.
For example, suppose we have a TCP-based network data protocol where
messages consist of the following:
* `message_length` - the number of bytes in the message as a
big-endian 32-bit integer
* `list_size` - the number of items in the following list of items
as a big-endian 32-bit integer
* zero or more items of the following data:
* a big-endian 64-bit floating point number
* a string that starts with a big-endian 32-bit integer that
specifies the length of the string, followed by a number of
bytes that represent the string
A message would be something like this:
```
[message_length][list_size][float1][string1][float2][string2]...
```
The following program uses a write buffer to encode an array of
tuples as a message of this type:
```pony
use "buffered"
actor Main
new create(env: Env) =>
let wb = Writer
let messages = [[(F32(3597.82), "Anderson"); (F32(-7979.3), "Graham")]
[(F32(3.14159), "Hopper"); (F32(-83.83), "Jones")]]
for items in messages.values() do
wb.i32_be((items.size() / 2).i32())
for (f, s) in items.values() do
wb.f32_be(f)
wb.i32_be(s.size().i32())
wb.write(s.array())
end
let wb_msg = Writer
wb_msg.i32_be(wb.size().i32())
wb_msg.writev(wb.done())
env.out.writev(wb_msg.done())
end
```
"""
var _chunks: Array[ByteSeq] iso = recover Array[ByteSeq] end
var _current: Array[U8] iso = recover Array[U8] end
var _size: USize = 0
fun ref reserve_chunks(size': USize) =>
"""
Reserve space for size' chunks.
This needs to be recalled after every call to `done`
as `done` resets the chunks.
"""
_chunks.reserve(size')
fun ref reserve_current(size': USize) =>
"""
Reserve space for size bytes in `_current`.
"""
_current.reserve(_current.size() + size')
fun size(): USize =>
_size
fun ref u8(data: U8) =>
"""
Write a byte to the buffer.
"""
let num_bytes = U8(0).bytewidth()
_current.push_u8(data)
_size = _size + num_bytes
fun ref u16_le(data: U16) =>
"""
Write a U16 to the buffer in little-endian byte order.
"""
let num_bytes = U16(0).bytewidth()
ifdef littleendian then
_current.push_u16(data)
else
_current.push_u16(data.bswap())
end
_size = _size + num_bytes
fun ref u16_be(data: U16) =>
"""
Write a U16 to the buffer in big-endian byte order.
"""
let num_bytes = U16(0).bytewidth()
ifdef bigendian then
_current.push_u16(data)
else
_current.push_u16(data.bswap())
end
_size = _size + num_bytes
fun ref i16_le(data: I16) =>
"""
Write an I16 to the buffer in little-endian byte order.
"""
u16_le(data.u16())
fun ref i16_be(data: I16) =>
"""
Write an I16 to the buffer in big-endian byte order.
"""
u16_be(data.u16())
fun ref u32_le(data: U32) =>
"""
Write a U32 to the buffer in little-endian byte order.
"""
let num_bytes = U32(0).bytewidth()
ifdef littleendian then
_current.push_u32(data)
else
_current.push_u32(data.bswap())
end
_size = _size + num_bytes
fun ref u32_be(data: U32) =>
"""
Write a U32 to the buffer in big-endian byte order.
"""
let num_bytes = U32(0).bytewidth()
ifdef bigendian then
_current.push_u32(data)
else
_current.push_u32(data.bswap())
end
_size = _size + num_bytes
fun ref i32_le(data: I32) =>
"""
Write an I32 to the buffer in little-endian byte order.
"""
u32_le(data.u32())
fun ref i32_be(data: I32) =>
"""
Write an I32 to the buffer in big-endian byte order.
"""
u32_be(data.u32())
fun ref f32_le(data: F32) =>
"""
Write an F32 to the buffer in little-endian byte order.
"""
u32_le(data.bits())
fun ref f32_be(data: F32) =>
"""
Write an F32 to the buffer in big-endian byte order.
"""
u32_be(data.bits())
fun ref u64_le(data: U64) =>
"""
Write a U64 to the buffer in little-endian byte order.
"""
let num_bytes = U64(0).bytewidth()
ifdef littleendian then
_current.push_u64(data)
else
_current.push_u64(data.bswap())
end
_size = _size + num_bytes
fun ref u64_be(data: U64) =>
"""
Write a U64 to the buffer in big-endian byte order.
"""
let num_bytes = U64(0).bytewidth()
ifdef bigendian then
_current.push_u64(data)
else
_current.push_u64(data.bswap())
end
_size = _size + num_bytes
fun ref i64_le(data: I64) =>
"""
Write an I64 to the buffer in little-endian byte order.
"""
u64_le(data.u64())
fun ref i64_be(data: I64) =>
"""
Write an I64 to the buffer in big-endian byte order.
"""
u64_be(data.u64())
fun ref f64_le(data: F64) =>
"""
Write an F64 to the buffer in little-endian byte order.
"""
u64_le(data.bits())
fun ref f64_be(data: F64) =>
"""
Write an F64 to the buffer in big-endian byte order.
"""
u64_be(data.bits())
fun ref u128_le(data: U128) =>
"""
Write a U128 to the buffer in little-endian byte order.
"""
let num_bytes = U128(0).bytewidth()
ifdef littleendian then
_current.push_u128(data)
else
_current.push_u128(data.bswap())
end
_size = _size + num_bytes
fun ref u128_be(data: U128) =>
"""
Write a U128 to the buffer in big-endian byte order.
"""
let num_bytes = U128(0).bytewidth()
ifdef bigendian then
_current.push_u128(data)
else
_current.push_u128(data.bswap())
end
_size = _size + num_bytes
fun ref i128_le(data: I128) =>
"""
Write an I128 to the buffer in little-endian byte order.
"""
u128_le(data.u128())
fun ref i128_be(data: I128) =>
"""
Write an I128 to the buffer in big-endian byte order.
"""
u128_be(data.u128())
fun ref write(data: ByteSeq) =>
"""
Write a ByteSeq to the buffer.
"""
// if `data` is 1 cacheline or less in size
// copy it into the existing `_current` array
// to coalesce multiple tiny arrays
// into a single bigger array
if data.size() <= 64 then
match data
| let d: String =>
let a = d.array()
_current.copy_from(a, 0, _current.size(), a.size())
| let d: Array[U8] val =>
_current.copy_from(d, 0, _current.size(), d.size())
end
_size = _size + data.size()
else
_append_current()
_chunks.push(data)
_size = _size + data.size()
end
fun ref writev(data: ByteSeqIter) =>
"""
Write ByteSeqs to the buffer.
"""
for chunk in data.values() do
write(chunk)
end
fun ref done(): Array[ByteSeq] iso^ =>
"""
Return an array of buffered ByteSeqs and reset the Writer's buffer.
"""
_append_current()
_size = 0
_chunks = recover Array[ByteSeq] end
fun ref _append_current() =>
if _current.size() > 0 then
_chunks.push(_current = recover Array[U8] end)
end
| pony | 137581 | https://nn.wikipedia.org/wiki/Fibonaccif%C3%B8lgja | Fibonaccifølgja | Fibonaccifølgja er ei følgje av tal der kvart tal unntatt dei to første er summen av dei to føregåande. I sin vidaste definisjon kan dei to første tala vere kva som helst, men mest vanleg er å starte på anten 1 og 1 eller 0 og 1:
eller
.
Historie
Fibonaccifølgja har namn etter Leonardo Fibonacci sitt forsøk på å beskrive populasjonsvekst hjå ei tenkt gruppe kaninar.
Ho blei likevel omtalt mykje tidlegare. Innan gammal indisk matematikk blei ho brukt til å studera prosodi i sanskrit. Innan verselæra på sanskrit ønska ein å finna alle mønster av lange (L) stavingar som er 2 einingar lange, og korte (K) stavingar som er 1 eining lang. Tel ein dei ulike mønstera av L og K med ei viss lengd får ein fibonaccifølgja: Talet på mønster som er m korte statvingar lang er fibonaccitalet Fm + 1.
Å finne fibonaccifølgja
Følgjande program i programmeringsspråket C genererer følgja av fibonaccital som ikkje overstig den maksimale verdien av den største heiltalsdatatypen i standardbiblioteket til C99. Dei to første tala er frivillige argument på kommandolinja.
#include <stdio.h>
#include <stdint.h>
int main(int argc, char *argv[]){
uintmax_t i=1, j=1;
if(argc == 3){
i = strtoll(argv[1], NULL, 0);
j = strtoll(argv[2], NULL, 0);
}
printf("%llu", i);
do{
printf("\n%llu", j);
i = i + j;
if(i < j) break;
printf("\n%llu", i);
j = j + i;
}while(j > i);
putchar('\n');
return 0;
}
Med to eitt-tal som start og 64 bit øvre talgrense, kjem desse 93 tala ut. Dette tek omkring 2 - 10 millisekund på ein moderne PC.
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24157817
39088169
63245986
102334155
165580141
267914296
433494437
701408733
1134903170
1836311903
2971215073
4807526976
7778742049
12586269025
20365011074
32951280099
53316291173
86267571272
139583862445
225851433717
365435296162
591286729879
956722026041
1548008755920
2504730781961
4052739537881
6557470319842
10610209857723
17167680177565
27777890035288
44945570212853
72723460248141
117669030460994
190392490709135
308061521170129
498454011879264
806515533049393
1304969544928657
2111485077978050
3416454622906707
5527939700884757
8944394323791464
14472334024676221
23416728348467685
37889062373143906
61305790721611591
99194853094755497
160500643816367088
259695496911122585
420196140727489673
679891637638612258
1100087778366101931
1779979416004714189
2880067194370816120
4660046610375530309
7540113804746346429
12200160415121876738
Kjelder
.
.
.
.
Heiltalsfølgjer
Matematiske relasjonar
Rekursjon | norwegian_nynorsk | 0.590057 |
Pony/files-FileWrite-.txt |
FileWrite¶
[Source]
primitive val FileWrite
Constructors¶
create¶
[Source]
new val create()
: FileWrite val^
Returns¶
FileWrite val^
Public Functions¶
value¶
[Source]
fun box value()
: U32 val
Returns¶
U32 val
eq¶
[Source]
fun box eq(
that: FileWrite val)
: Bool val
Parameters¶
that: FileWrite val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FileWrite val)
: Bool val
Parameters¶
that: FileWrite val
Returns¶
Bool val
| pony | 161775 | https://nn.wikipedia.org/wiki/Tolv%20sonatar%20for%20to%20fiolinar%20og%20basso%20continuo%2C%20Opus%201 | Tolv sonatar for to fiolinar og basso continuo, Opus 1 | Opus 1 er ei samling sonatar som Antonio Vivaldi komponerte i 1705.
Sonate nr. 1 i G-moll, RV 73
Sonate nr. 2 i E-moll, RV 67
Sonate nr. 3 i C-dur, RV 61
Sonate nr. 4 i E-dur, RV 66
Sonate nr. 5 i F-dur, RV 69
Sonate nr. 6 i D-dur, RV 62
Sonate nr. 7 i Ess-dur, RV 65
Sonate nr. 8 i D-moll, RV 64
Sonate nr. 9 i A-dur, RV 75
Sonate nr. 10 i B-dur, RV 78
Sonate nr. 11 i B-moll, RV 79
Sonate nr. 12 i D-moll, RV 63
Den siste sonaten er ei samling variasjonar over det kjende 'La Folia'-temaet.
Musikkverk av Antonio Vivaldi | norwegian_nynorsk | 1.216969 |
Pony/net-UDPAuth-.txt |
UDPAuth¶
[Source]
primitive val UDPAuth
Constructors¶
create¶
[Source]
new val create(
from: (AmbientAuth val | NetAuth val))
: UDPAuth val^
Parameters¶
from: (AmbientAuth val | NetAuth val)
Returns¶
UDPAuth val^
Public Functions¶
eq¶
[Source]
fun box eq(
that: UDPAuth val)
: Bool val
Parameters¶
that: UDPAuth val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: UDPAuth val)
: Bool val
Parameters¶
that: UDPAuth val
Returns¶
Bool val
| pony | 90669 | https://sv.wikipedia.org/wiki/Ulster%20Unionist%20Party | Ulster Unionist Party | Ulster Unionist Party, förkortat UUP, är det ena av de två största unionistiska partierna i Nordirland. Partiet kallas ibland även Official Unionist Party (OUP). På svenska benämns partiet ibland Ulsters unionistparti eller Ulsterunionisterna. Fram till 2003 var UUP det största unionistiska partiet i Nordirland, men vid valet i Nordirland 2003 fick Democratic Unionist Party fler röster och mandat.
UUP bildades den 3 mars 1905 i Ulster Hall i Belfast, under namnet Irish Unionist Party. Partiets främsta syfte var att motverka införande av home rule för Irland. Partiet hade från början och ända fram till år 2005 formella band med Oranienorden. I och med delningen av Irland i början av 1920-talet delades också den irländska unionismen och ett separat Ulster-parti upprättades. Partiet blev det största i Nordirland och var under åren 1921–1972 regeringsparti i den självstyrande regeringen i Nordirland.
Partiledare från 1995–2005 var David Trimble, som avgick efter det för partiet katastrofala parlamentsvalet i Storbritannien 2005, då fem av UUP:s sex parlamentsledamöter, bland andra Trimble själv, förlorade sina platser. Han efterträddes av 24 juni 2005 sir Reg Empey. UUP:s nuvarande partiledare heter Mike Nesbitt och tillträdde posten 31 mars 2012.
Övrigt
Intressant att notera är att de två förra partiledarna, UUP:s David Trimble och SDLP:s John Hume tillsammans belönades med Nobels fredspris år 1998 för sina ansträngningar att skapa fred i den härjade provinsen. Det var på långfredagen 1998 som man undertecknade fredsavtalet långfredagsavtalet ("The Good Friday Agreement"), som till exempel slog fast att partier bara får använda fredliga och demokratiska medel i sitt arbete, att alla medborgare ska ha samma ekonomiska, kulturella och sociala rättigheter, och att en avväpning av de paramilitära grupperna skulle ske.
Externa länkar
Officiell webbplats
Konservativa partier i Storbritannien
Politiska partier bildade 1905
Politiska partier i Nordirland | swedish | 1.040442 |
Pony/promises-Promises-.txt |
Promises[A: Any #share]¶
[Source]
primitive val Promises[A: Any #share]
Constructors¶
create¶
[Source]
new val create()
: Promises[A] val^
Returns¶
Promises[A] val^
Public Functions¶
join¶
[Source]
Create a promise that is fulfilled when all promises in the given sequence
are fulfilled. If any promise in the sequence is rejected then the new
promise is also rejected. The order that values appear in the final array
is based on when each promise is fulfilled and not the order that they are
given.
Join three existing promises to make a fourth.
use "promises"
actor Main
new create(env: Env) =>
let p1 = Promise[String val]
let p2 = Promise[String val]
let p3 = Promise[String val]
Promises[String val].join([p1; p2; p3].values())
.next[None]({(a: Array[String val] val) =>
for s in a.values() do
env.out.print(s)
end
})
p2("second")
p3("third")
p1("first")
fun box join(
ps: Iterator[Promise[A] tag] ref)
: Promise[Array[A] val] tag
Parameters¶
ps: Iterator[Promise[A] tag] ref
Returns¶
Promise[Array[A] val] tag
eq¶
[Source]
fun box eq(
that: Promises[A] val)
: Bool val
Parameters¶
that: Promises[A] val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: Promises[A] val)
: Bool val
Parameters¶
that: Promises[A] val
Returns¶
Bool val
| pony | 273484 | https://da.wikipedia.org/wiki/IBATIS | IBATIS | iBATIS er et stykke fri software, der automatisk eller semi-automatisk laver objekter til programmeringssprogene java, C# eller ruby ud fra SQL. Programmøren skal ikke skrive SQL direkte i sin kode men i stedet skrive det i XML-filer.
Ideen med iBATES er at mindske mængden af kode en programmør skal skrive for at et program kan arbejde med data i en relationel database.
Hvis der i en database eksistere en tabel PRODUCT (PRD_ID: INTEGER, PRD_DESCRIPTION: VARCHAR) og man ønsker adgang til værdierne i en række i tabellen via et java-objekt com.example.Product (id: int, description: String) så kan iBATES lave java-objektet ved at skrive følgende i en XML-fil:
<select id="getProduct"
parameterClass="com.example.Product"
resultClass="com.example.Product">
select
PRD_ID as id,
PRD_DESCRIPTION as description
from
PRODUCT
where
PRD_ID = #id#
</select>
Java-koden der bruger Product-objektet til at hente værdier fra en bestemt række i tabellen i databasen kan se sådan her ud:
Product paramProduct = new Product();
paramProduct.setId(123);
Product resultProduct = IBatis.getObject("getProduct", paramProduct);
Eksterne links
ibatis.apache.org – Den officielle side.
Fri software | danish | 0.816977 |
Pony/collections-persistent-Set-.txt |
Set[A: (Hashable val & Equatable[A])]¶
[Source]
type Set[A: (Hashable val & Equatable[A])] is
HashSet[A, HashEq[A] val] val
Type Alias For¶
HashSet[A, HashEq[A] val] val
| pony | 318725 | https://no.wikipedia.org/wiki/A | A | Denne artikkelen omhandler bokstaven A. For annet bruk se A (andre betydninger).
Av tekniske grunner blir A# sendt hit, for programmeringsspråket A#.NET se A Sharp eller A# (Axiom) se A Sharp (Axiom)
A, a er den første bokstaven i det latinske alfabetet.
Den tilhører den gruppen bokstaver vi kaller vokaler.
Koder for datamaskinen
Alternative representasjoner av A
Bruk
A er nasjonalt kjennemerke for biler fra Østerrike.
Referanser
Eksterne lenker
A 01
new:प्रिथिबी | norwegian_bokmål | 1.034619 |
Pony/collections-persistent-Map-.txt |
Map[K: (Hashable val & Equatable[K]), V: Any #share]¶
[Source]
A map that uses structural equality on the key.
type Map[K: (Hashable val & Equatable[K]), V: Any #share] is
HashMap[K, V, HashEq[K] val] val
Type Alias For¶
HashMap[K, V, HashEq[K] val] val
| pony | 2812746 | https://sv.wikipedia.org/wiki/Knipemyst | Knipemyst | Knipemyst är en sjö i Kungsbacka kommun i Halland och ingår i . Knipemyst ligger i Natura 2000-område. Sjön är meter djup, har en yta på kvadratkilometer och är belägen meter över havet.
Se även
Lista över insjöar i Kungsbacka kommun
Källor
Externa länkar
Insjöar i Kungsbackaån-Göta älvs kustområde
Insjöar i Halland
Insjöar i Kungsbacka kommun | swedish | 1.163845 |
Pony/combining-capabilities.txt | # Combining Capabilities
When we talked about fields in the [classes](/types/classes.md) and [variables](/expressions/variables.md) chapters, we passed over the detail of field capabilities. Fields, just like variables, have their own capabilities! A `val` field still refers to something permanently immutable. A `tag` field still can't be read from. An `iso` field is still globally unique: it can only be accessed except through this field of a single instance.
Once we have fields with capabilities inside objects with capabilities, now we have two capabilities to keep track of. When a field of an object is accessed or extracted, its reference capability depends both on the reference capability of the field and the reference capability of the __origin__, that is, the object the __field__ is being read from. We have to pick a capability for the combination that maintains the guarantees for both the __origin__ reference capability, and for the capability of the __field__.
## Viewpoint adaptation
The process of combining origin and field capabilities is called __viewpoint adaptation__. That is, the __origin__ has a __viewpoint__, and its fields can be "seen" only from that __viewpoint__.
Let's start with a table. This shows how a __field__ of each capability looks when using an __origin__ of each capability.
---
| ▷ | `iso` field | `trn` field | `ref` field | `val` field | `box` field | `tag` field |
| -------------- | --------- | --------- | --------- | --------- | --------- | --------- |
| __`iso` origin__ | `iso` | `tag` | `tag` | `val` | `tag` | `tag` |
| __`trn` origin__ | `iso` | `box` | `box` | `val` | `box` | `tag` |
| __`ref` origin__ | `iso` | `trn` | `ref` | `val` | `box` | `tag` |
| __`val` origin__ | `val` | `val` | `val` | `val` | `val` | `tag` |
| __`box` origin__ | `tag` | `box` | `box` | `val` | `box` | `tag` |
| __`tag` origin__ | n/a | n/a | n/a | n/a | n/a | n/a |
---
For example, if you have a `trn` origin and you read a `ref` field, you get a `box` result:
```pony
class Foo
var x: String ref
class Bar
fun f() =>
var y: Foo trn = get_foo_trn()
var z: String box = y.x
```
## Explaining why
That table will seem totally natural to you, eventually. But probably not yet. To help it seem natural, let's walk through each cell in the table and explain why it is the way it is.
### Reading from an `iso` variable
Anything read through an `iso` origin has to maintain the isolation guarantee that the origin has. The key thing to remember is that the `iso` can be sent to another actor and it can also become any other reference capability. So when we read a field, we need to get a result that won't ever break the isolation guarantees that the origin makes, that is, _read and write uniqueness_.
An `iso` field makes the same guarantees as an `iso` origin, so that's fine to read. A `val` field is _globally immutable_, which means it's always ok to read it, no matter what the origin is (well, other than `tag`).
Everything else, though, can break our isolation guarantees. That's why other reference capabilities are seen as `tag`: it's the only type that is neither readable nor writable.
### Reading from a `trn` variable
This is like `iso`, but with a weaker guarantee (_write uniqueness_ as opposed to _read and write uniqueness_). That makes a big difference since now we can return something readable when we enforce our guarantees.
An `iso` field makes stronger guarantees than `trn`, and can't alias anything readable inside the `trn` origin, so it's perfectly safe to read.
On the other hand, `trn` and `ref` fields have to be returned as `box`. It might seem a bit odd that `trn` has to be returned as `box`, since after all it guarantees write uniqueness itself and we might expect it to behave like `iso`. The issue is that `trn`, unlike `iso`, *can* alias with some `box` variables in the origin. And that `trn` origin still has to make the guarantee that nothing else can write to fields that it can read. On the other hand, `trn` still can't be returned as `val`, because then we might leave the original field in place and create a `val` alias, while that field can still be used to write! So we have to view it as `box`.
Immutable and opaque capabilities, though, can never violate write uniqueness, so `val`, `box`, and `tag` are viewed as themselves.
### Reading from a `ref` variable
A `ref` origin doesn't modify its fields at all. This is because a `ref` origin doesn't make any guarantees that are incompatible with its fields.
### Reading from a `val` variable
A `val` origin is deeply and globally immutable, so all of its fields are also `val`. The only exception is a `tag` field. Since we can't read from it, we also can't guarantee that nobody can write to it, so it stays `tag`.
### Reading from a `box` variable
A `box` variable is locally immutable. This means it's possible that it may be mutated through some other variable (a `trn` or a `ref`), but it's also possible that our `box` variable is an alias of some `val` variable.
When we read a field, we need to return a reference capability that is compatible with the field but is also locally immutable.
An `iso` field is returned as a `tag` because no locally immutable reference capability can maintain its isolation guarantees. A `val` field is returned as a `val` because global immutability is a stronger guarantee than local immutability. A `box` field makes the same local immutability guarantee as its origin, so that's also fine.
For `trn` and `ref` we need to return a locally immutable reference capability that doesn't violate any guarantees the field makes. In both cases, we can return `box`.
### Reading from a `tag` variable
This one is easy: `tag` variables are opaque! They can't be read from.
## Writing to the field of an object
Like reading the field of an object, writing to a field depends on the reference capability of the object reference being stored and the reference capability of the origin object containing the field. The reference capability of the object being stored must not violate the guarantees made by the origin object's reference capability. For example, a `val` object reference can be stored in an `iso` origin. This is because the `val` reference capability guarantees that no alias to that object exists which could violate the guarantees that the `iso` capability makes.
Here's a simplified version of the table above that shows which reference capabilities can be stored in the field of an origin object.
---
| ◁ | `iso` object | `trn` object | `ref` object | `val` object | `box` object | `tag` object |
| -------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- |
| __`iso` origin__ | ✔ | | | ✔ | | ✔ |
| __`trn` origin__ | ✔ | ✔ | | ✔ | | ✔ |
| __`ref` origin__ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| __`val` origin__ | | | | | | |
| __`box` origin__ | | | | | | |
| __`tag` origin__ | | | | | | |
---
The bottom half of this chart is empty, since only origins with a mutable capability can have their fields modified.
| pony | 79723 | https://sv.wikipedia.org/wiki/Klass%20%28programmering%29 | Klass (programmering) | Klass är i objektorienterad programmering ett avsnitt programkod som samlar en mängd relaterade attribut och funktioner, även kallat metoder. Det är ett viktigt kännetecken för en klass att dess inre struktur inte är tillgänglig utanför klassen, utan den kan enbart manipuleras genom ett specificerat gränssnitt. Fenomenet att en klass privata delar ej är tillgängliga utanför kallas inkapsling (eng. encapsulation). En klass kan sägas vara en användardefinierad datatyp, som alltså kompletterar de fördefinierade datatyperna, i C++ till exempel int och char. För att de klasserna skall likna just användardefinierade datatyper använder man i vissa språk överlagring av operatorer för klasser.
Arvshierarkier
Objektorienterade programmeringsspråk tillåter klasser att ärva egenskaper från andra klasser i ett eller flera led. En klass som en annan klass ärver egenskaper ifrån kallas för superklass (överklass, basklass) medan den klass som ärver egenskaperna benämns subklass (underklass, härledd klass).
Exempel på klass i C++
#include <string>
class example
{
public:
example(int no, string s); //Konstruktor
void add(int no); //Metod för att addera värden med variabeln "value"
void subtract(int no); //Metod för att subtrahera från variabeln "value"
void change_name(string s); //Metod för att ändra innehållet i strängvariabeln "name"
protected:
int value; //En heltalsvariabel
std::string name; //En strängvariabel
};
example::example(int no, string s)
{
value = no; //Initering av de båda variablerna
name = s;
}
void example::add(int no)
{
value += no; //"no" adderas till "value"
}
void example::subtract(int no)
{
value -= no; //"no" subtraheras från "value"
}
void example::change_name(string s)
{
name = s; //name ändras till s
}
int main()
{
example test(10, "test"); //Objektet "test" initieras, value = 10, name = test
test.add(10); //"value" ökar med 10
test.subtract(5); //"value" minskar med 5, innehåller just nu 15
test.change_name("example"); //Variabeln "name" ändras från "test" till "example"
return 0;
}
Koden ovan definierar en klass som består av en variabel av typen int och en variabel av typen string (som inte är en primitiv datatyp, utan en egen klass). Dessutom anges metoder för att manipulera dessa värden, men inte för att hämta information från klassen. Ingen utskrift kan därför heller ske i huvudprogrammet, eftersom datan har gömts för alla utom arvingar till klassen (se vidare nedan).
Exempel på en subklass i C++
Exempleklassen ovan saknar vissa metoder som kan vara bra att ha och dessutom kanske man vill kunna lagra ytterligare värden förutom ett heltal och en textsträng. Ett alternativ är då att skapa en subklass till klassen exempel (i stället för att skriva om koden till klassen example). Det ser ut så här:
class betterexample : public example
{
//En klass är default private, alltså måste följande rad inte skrivas.
//private:
double anothervalue; //Ett attribut av typen double
public:
betterexample(int no, string s, double an); //Konstruktor
int getValue(); //Metod för att komma åt "value", som finns i superklassen
string getName(); //Metod för att hämta "name", som också finns i superklassen
double getAnothervalue(); //Metod för att hämta "anothervalue", som bara finns i subklassen
};
betterexample::betterexample(int no, string s, double an): example(no, s) //Anrop till superklassens konstruktor
{
anothervalue = an; //Initiering av den egna variabeln
}
int betterexample::getValue()
{
return value; //Hämtar "value" som definierats i superklassen
}
string betterexample::getName()
{
return name; //Hämtar "name" som definierats i superklassen
}
double betterexample::getAnothervalue()
{
return anothervalue; //Hämtar "anothervalue" som definierats på plats i subklassen
}
Här ärver klassen "betterexample" alla attribut och metoder från klassen example. Därtill definieras ett eget attribut, ett flyttal kallat "anothervalue" liksom metoder som kan användas för att hämta alla värden som lagras i klassen. Om man lägger till koden för "betterexample" till den som redan finns för "example" skulle man kunna definiera ett huvudprogram som ser ut så här:
int main()
{
betterexample nytt_test(10, "nytt test", 20.5); //Skapar ett objekt av typen "betterexample"
nytt_test.add(20); //adderar 20 till heltalet "value"
cout << nytt_test.getValue() << endl; //skriver ut värdet av "value"
cout << nytt_test.getAnothervalue() << endl; //Skriver ut värdet av "anothervalue"
cout << nytt_test.getName() << endl; //Skriver ut värdet av "name"
return 0;
}
Utskriften från detta program blir:
30
20.5
nytt test
Abstrakt klass
I objektorienterad programmering kan abstrakta klasser definieras.
Detta är klasser som inte kan instansieras, vilket innebär att det inte går att skapa objekt av klassen. I stället får man definiera en klass som ärver den abstrakta, och på så sätt skapa objekt.
Ett exempel kan vara klassen Däggdjur. I den kan definieras egenskaper och metoder som är gemensamma för alla däggdjur, men ett antal egenskaper som storlek, dräktighetstid etc kan inte definieras utan att veta vilket djur det rör sig om. Typiskt anger Däggdjur att det har en längd, men kan inte svara på hur stor den är.
Genom att definiera Människa och Delfin som klasser som ärver Däggdjur, och tillföra specifika egenskaper och metoder för sådant som skiljer, kan man både få god utvecklingsekonomi och en beskrivande struktur.
Abstrakta klasser är också praktiska för användare. Ett program för en zoologisk trädgård har troligen behov av att hålla kollektioner av objekt som har klassen Däggdjur eller rentav Djur, och nöjer sig med att respektive objekt själv vet vilken klass det egentligen implementerar.
Interface kan ses som ett specialfall av abstrakta klasser. Dessa innehåller enbart definitioner av metoder, och ingen implementering alls.
Programspråkselement
Objektorienterad programmering | swedish | 0.805182 |
Pony/collections-persistent-Cons-.txt |
Cons[A: A]¶
[Source]
A list with a head and a tail, where the tail can be empty.
class val Cons[A: A] is
ReadSeq[val->A] box
Implements¶
ReadSeq[val->A] box
Constructors¶
create¶
[Source]
new val create(
a: val->A,
t: (Cons[A] val | Nil[A] val))
: Cons[A] val^
Parameters¶
a: val->A
t: (Cons[A] val | Nil[A] val)
Returns¶
Cons[A] val^
Public Functions¶
size¶
[Source]
Returns the size of the list.
fun box size()
: USize val
Returns¶
USize val
apply¶
[Source]
Returns the i-th element of the list. Errors if the index is out of bounds.
fun box apply(
i: USize val)
: val->A ?
Parameters¶
i: USize val
Returns¶
val->A ?
values¶
[Source]
Returns an iterator over the elements of the list.
fun box values()
: Iterator[val->A] ref^
Returns¶
Iterator[val->A] ref^
is_empty¶
[Source]
Returns a Bool indicating if the list is empty.
fun box is_empty()
: Bool val
Returns¶
Bool val
is_non_empty¶
[Source]
Returns a Bool indicating if the list is non-empty.
fun box is_non_empty()
: Bool val
Returns¶
Bool val
head¶
[Source]
Returns the head of the list.
fun box head()
: val->A
Returns¶
val->A
tail¶
[Source]
Returns the tail of the list.
fun box tail()
: (Cons[A] val | Nil[A] val)
Returns¶
(Cons[A] val | Nil[A] val)
reverse¶
[Source]
Builds a new list by reversing the elements in the list.
fun val reverse()
: (Cons[A] val | Nil[A] val)
Returns¶
(Cons[A] val | Nil[A] val)
prepend¶
[Source]
Builds a new list with an element added to the front of this list.
fun val prepend(
a: val->A!)
: Cons[A] val
Parameters¶
a: val->A!
Returns¶
Cons[A] val
concat¶
[Source]
Builds a new list that is the concatenation of this list and the provided
list.
fun val concat(
l: (Cons[A] val | Nil[A] val))
: (Cons[A] val | Nil[A] val)
Parameters¶
l: (Cons[A] val | Nil[A] val)
Returns¶
(Cons[A] val | Nil[A] val)
map[B: B]¶
[Source]
Builds a new list by applying a function to every member of the list.
fun val map[B: B](
f: {(val->A): val->B}[A, B] box)
: (Cons[B] val | Nil[B] val)
Parameters¶
f: {(val->A): val->B}[A, B] box
Returns¶
(Cons[B] val | Nil[B] val)
flat_map[B: B]¶
[Source]
Builds a new list by applying a function to every member of the list and
using the elements of the resulting lists.
fun val flat_map[B: B](
f: {(val->A): List[B]}[A, B] box)
: (Cons[B] val | Nil[B] val)
Parameters¶
f: {(val->A): List[B]}[A, B] box
Returns¶
(Cons[B] val | Nil[B] val)
for_each¶
[Source]
Applies the supplied function to every element of the list in order.
fun val for_each(
f: {(val->A)}[A] box)
: None val
Parameters¶
f: {(val->A)}[A] box
Returns¶
None val
filter¶
[Source]
Builds a new list with those elements that satisfy a provided predicate.
fun val filter(
f: {(val->A): Bool}[A] box)
: (Cons[A] val | Nil[A] val)
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
(Cons[A] val | Nil[A] val)
fold[B: B]¶
[Source]
Folds the elements of the list using the supplied function.
fun val fold[B: B](
f: {(B, val->A): B^}[A, B] box,
acc: B)
: B
Parameters¶
f: {(B, val->A): B^}[A, B] box
acc: B
Returns¶
B
every¶
[Source]
Returns true if every element satisfies the provided predicate, false
otherwise.
fun val every(
f: {(val->A): Bool}[A] box)
: Bool val
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
Bool val
exists¶
[Source]
Returns true if at least one element satisfies the provided predicate,
false otherwise.
fun val exists(
f: {(val->A): Bool}[A] box)
: Bool val
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
Bool val
partition¶
[Source]
Builds a pair of lists, the first of which is made up of the elements
satisfying the supplied predicate and the second of which is made up of
those that do not.
fun val partition(
f: {(val->A): Bool}[A] box)
: ((Cons[A] val | Nil[A] val) , (Cons[A] val | Nil[A] val))
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
((Cons[A] val | Nil[A] val) , (Cons[A] val | Nil[A] val))
drop¶
[Source]
Builds a list by dropping the first n elements.
fun val drop(
n: USize val)
: (Cons[A] val | Nil[A] val)
Parameters¶
n: USize val
Returns¶
(Cons[A] val | Nil[A] val)
drop_while¶
[Source]
Builds a list by dropping elements from the front of the list until one
fails to satisfy the provided predicate.
fun val drop_while(
f: {(val->A): Bool}[A] box)
: (Cons[A] val | Nil[A] val)
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
(Cons[A] val | Nil[A] val)
take¶
[Source]
Builds a list of the first n elements.
fun val take(
n: USize val)
: (Cons[A] val | Nil[A] val)
Parameters¶
n: USize val
Returns¶
(Cons[A] val | Nil[A] val)
take_while¶
[Source]
Builds a list of elements satisfying the provided predicate until one does
not.
fun val take_while(
f: {(val->A): Bool}[A] box)
: (Cons[A] val | Nil[A] val)
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
(Cons[A] val | Nil[A] val)
| pony | 3062232 | https://sv.wikipedia.org/wiki/Aglossa%20acallalis | Aglossa acallalis | Aglossa acallalis är en fjärilsart som beskrevs av Dyar 1908. Aglossa acallalis ingår i släktet Aglossa och familjen mott. Inga underarter finns listade i Catalogue of Life.
Källor
Externa länkar
Mott
acallalis | swedish | 1.138278 |
Pony/files--index-.txt |
Files package¶
The Files package provides classes for working with files and
directories.
Files are identified by FilePath objects, which represent both the
path to the file and the capabilites for accessing the file at that
path. FilePath objects can be used with the CreateFile and
OpenFile primitives and the File class to get a reference to a
file that can be used to write to and/or read from the file. It can
also be used with the Directory object to get a reference to a
directory object that can be used for directory operations.
The FileLines class allows a file to be accessed one line at a time.
The FileStream actor provides the ability to asynchronously write to
a file.
The Path primitive can be used to do path-related operations on
strings and characters.
Example program¶
This program opens the files that are given as command line arguments
and prints their contents.
use "files"
actor Main
new create(env: Env) =>
for file_name in env.args.slice(1).values() do
let path = FilePath(FileAuth(env.root), file_name)
match OpenFile(path)
| let file: File =>
while file.errno() is FileOK do
env.out.write(file.read(1024))
end
else
env.err.print("Error opening file '" + file_name + "'")
end
end
Public Types¶
primitive CreateFile
class Directory
class File
primitive FileAuth
primitive FileBadFileNumber
type FileCaps
primitive FileChmod
primitive FileChown
primitive FileCreate
primitive FileEOF
type FileErrNo
primitive FileError
primitive FileExec
primitive FileExists
class FileInfo
class FileLines
primitive FileLink
primitive FileLookup
primitive FileMkdir
class FileMode
primitive FileOK
class FilePath
primitive FilePermissionDenied
primitive FileRead
primitive FileRemove
primitive FileRename
primitive FileSeek
primitive FileStat
actor FileStream
primitive FileSync
primitive FileTime
primitive FileTruncate
primitive FileWrite
primitive OpenFile
primitive Path
interface WalkHandler
| pony | 3128657 | https://sv.wikipedia.org/wiki/Cadrema%20praeapicalis | Cadrema praeapicalis | Cadrema praeapicalis är en tvåvingeart som först beskrevs av Oswald Duda 1934. Cadrema praeapicalis ingår i släktet Cadrema och familjen fritflugor. Inga underarter finns listade i Catalogue of Life.
Källor
Fritflugor
praeapicalis | swedish | 1.254844 |
Pony/src-builtin-any-.txt |
any.pony
1interface tag Any
| pony | 77442 | https://da.wikipedia.org/wiki/Pony | Pony | En pony er en lille hest som er under 148 cm høj, målt over manken. Der findes forskellige ponyracer, der opdeles i forskellige underkategorier.
Ponyer har en kraftigere man, pels og hale end heste. De har proportionelt kortere og kraftigere ben, bredere brystparti, kraftigere skelet samt kraftigere, men kortere hoveder.
Ponyer stammer fra vilde hesteracer, der har udviklet størrelse efter deres omgivelser. De er tæmmet og videreudviklet gennem avl, specielt i nordeuropæiske lande og regioner som Norge, Island, Irland, Shetland og Skotland.
I henhold til Dansk Rideforbunds regler, må en pony have et stangmål på maksimalt 148 cm uden sko. Ponyerne opdeles i tre forskellige kategorier baseret på størrelse.
Som udgangspunkt er heste højere end ponyer, men der er undtagelser. Eksempelvis bliver en falabellaheste betegnet som en hest, og en shetlænder som en pony, selvom sidstnævnte er højest.
Ponyer har desuden ry for at have et lidt mildere temperament end heste.
Der kan endvidere være nogle økonomiske fordele ved at eje en pony frem for en hest. Fx behøver en pony generelt mindre staldplads og mindre foder end en hest.
Eksempler på ponyracer
Amerikansk walking pony
Connemara
Shetlandspony
New Forest-pony
Gotlandsruss
Welsh Mountain pony
Fjordhest
Welsh pony
Noter
Hesteracer | danish | 1.142681 |
Pony/src-net-net_address-.txt |
net_address.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199use @ntohl[U32](netlong: U32)
use @ntohs[U16](netshort: U16)
use @pony_os_ipv4[Bool](addr: NetAddress tag)
use @pony_os_ipv6[Bool](addr: NetAddress tag)
use @ponyint_address_length[U32](addr: NetAddress tag)
use @pony_os_nameinfo[Bool](addr: NetAddress tag,
host: Pointer[Pointer[U8] iso] tag, serv: Pointer[Pointer[U8] iso] tag,
reverse_dns: Bool, service_name: Bool)
class val NetAddress is Equatable[NetAddress]
"""
Represents an IPv4 or IPv6 address. The family field indicates the address
type. The addr field is either the IPv4 address or the IPv6 flow info. The
addr1-4 fields are the IPv6 address, or invalid for an IPv4 address. The
scope field is the IPv6 scope, or invalid for an IPv4 address.
This class is modelled after the C data structure for holding socket
addresses for both IPv4 and IPv6 `sockaddr_storage`.
Use the `name` method to obtain address/hostname and port/service as Strings.
"""
let _family: U16 = 0
let _port: U16 = 0
"""
Port number in network byte order.
"""
let _addr: U32 = 0
"""
IPv4 address in network byte order.
Will be `0` for IPv6 addresses. Check with `ipv4()` and `ipv6()`.
"""
let _addr1: U32 = 0
"""
Bits 0-32 of the IPv6 address in network byte order.
`0` if this is an IPv4 address. Check with `ipv4()` and `ipv6()`.
"""
let _addr2: U32 = 0
"""
Bits 33-64 of the IPv6 address in network byte order.
`0` if this is an IPv4 address. Check with `ipv4()` and `ipv6()`.
"""
let _addr3: U32 = 0
"""
Bits 65-96 of the IPv6 address in network byte order.
`0` if this is an IPv4 address. Check with `ipv4()` and `ipv6()`.
"""
let _addr4: U32 = 0
"""
Bits 97-128 of the IPv6 address in network byte order.
`0` if this is an IPv4 address. Check with `ipv4()` and `ipv6()`.
"""
let _scope: U32 = 0
"""IPv6 scope identifier: Unicast, Anycast, Multicast and unassigned scopes."""
fun ip4(): Bool =>
"""
Returns true for an IPv4 address.
"""
@pony_os_ipv4(this)
fun ip6(): Bool =>
"""
Returns true for an IPv6 address.
"""
@pony_os_ipv6(this)
fun name(
reversedns: (DNSAuth | None) = None,
servicename: Bool = false)
: (String, String) ?
=>
"""
Returns the host and service name.
If `reversedns` is `DNSAuth`,
a DNS lookup will be executed and the hostname
for this address is returned as first element of the result tuple.
If no hostname could be found, an error is raised.
If `reversedns` is `None` the plain IP address is given
and no DNS lookup is executed.
If `servicename` is `false` the numeric port is returned
as second element of the result tuple.
If it is `true` the port is translated into its
corresponding servicename (e.g. port 80 is returned as `"http"`).
Internally this method uses the POSIX C function `getnameinfo`.
"""
var host: Pointer[U8] iso = recover Pointer[U8] end
var serv: Pointer[U8] iso = recover Pointer[U8] end
let reverse = reversedns isnt None
if not
@pony_os_nameinfo(this, addressof host, addressof serv, reverse,
servicename)
then
error
end
(recover String.from_cstring(consume host) end,
recover String.from_cstring(consume serv) end)
fun eq(that: NetAddress box): Bool =>
(this._family == that._family)
and (this._port == that._port)
and (host_eq(that))
and (this._scope == that._scope)
fun host_eq(that: NetAddress box): Bool =>
if ip4() then
this._addr == that._addr
else
(this._addr1 == that._addr1)
and (this._addr2 == that._addr2)
and (this._addr3 == that._addr3)
and (this._addr4 == that._addr4)
end
fun length() : U8 =>
"""
For platforms (OSX/FreeBSD) with `length` field as part of
its `struct sockaddr` definition, returns the `length`.
Else (Linux/Windows) returns the size of `sockaddr_in` or `sockaddr_in6`.
"""
ifdef linux or windows then
(@ponyint_address_length(this)).u8()
else
ifdef bigendian then
((_family >> 8) and 0xff).u8()
else
(_family and 0xff).u8()
end
end
fun family() : U8 =>
"""
Returns the `family`.
"""
ifdef linux or windows then
ifdef bigendian then
((_family >> 8) and 0xff).u8()
else
(_family and 0xff).u8()
end
else
ifdef bigendian then
(_family and 0xff).u8()
else
((_family >> 8) and 0xff).u8()
end
end
fun port() : U16 =>
"""
Returns port number in host byte order.
"""
@ntohs(_port)
fun scope() : U32 =>
"""
Returns IPv6 scope identifier: Unicast, Anycast, Multicast and
unassigned scopes.
"""
@ntohl(_scope)
fun ipv4_addr() : U32 =>
"""
Returns IPV4 address (`_addr` field in the class) if `ip4()` is `True`.
If `ip4()` is `False` then the contents are invalid.
"""
@ntohl(_addr)
fun ipv6_addr() : (U32, U32, U32, U32) =>
"""
Returns IPV6 address as the 4-tuple (say `a`).
`a._1 = _addr1` // Bits 0-32 of the IPv6 address in host byte order.
`a._2 = _addr2 // Bits 33-64 of the IPv6 address in host byte order.
`a._3 = _addr3 // Bits 65-96 of the IPv6 address in host byte order.
`a._4 = _addr4 // Bits 97-128 of the IPv6 address in host byte order.
The contents of the 4-tuple returned are valid only if `ip6()` is `True`.
"""
(@ntohl(_addr1),
@ntohl(_addr2),
@ntohl(_addr3),
@ntohl(_addr4)
)
| pony | 137581 | https://nn.wikipedia.org/wiki/Fibonaccif%C3%B8lgja | Fibonaccifølgja | Fibonaccifølgja er ei følgje av tal der kvart tal unntatt dei to første er summen av dei to føregåande. I sin vidaste definisjon kan dei to første tala vere kva som helst, men mest vanleg er å starte på anten 1 og 1 eller 0 og 1:
eller
.
Historie
Fibonaccifølgja har namn etter Leonardo Fibonacci sitt forsøk på å beskrive populasjonsvekst hjå ei tenkt gruppe kaninar.
Ho blei likevel omtalt mykje tidlegare. Innan gammal indisk matematikk blei ho brukt til å studera prosodi i sanskrit. Innan verselæra på sanskrit ønska ein å finna alle mønster av lange (L) stavingar som er 2 einingar lange, og korte (K) stavingar som er 1 eining lang. Tel ein dei ulike mønstera av L og K med ei viss lengd får ein fibonaccifølgja: Talet på mønster som er m korte statvingar lang er fibonaccitalet Fm + 1.
Å finne fibonaccifølgja
Følgjande program i programmeringsspråket C genererer følgja av fibonaccital som ikkje overstig den maksimale verdien av den største heiltalsdatatypen i standardbiblioteket til C99. Dei to første tala er frivillige argument på kommandolinja.
#include <stdio.h>
#include <stdint.h>
int main(int argc, char *argv[]){
uintmax_t i=1, j=1;
if(argc == 3){
i = strtoll(argv[1], NULL, 0);
j = strtoll(argv[2], NULL, 0);
}
printf("%llu", i);
do{
printf("\n%llu", j);
i = i + j;
if(i < j) break;
printf("\n%llu", i);
j = j + i;
}while(j > i);
putchar('\n');
return 0;
}
Med to eitt-tal som start og 64 bit øvre talgrense, kjem desse 93 tala ut. Dette tek omkring 2 - 10 millisekund på ein moderne PC.
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24157817
39088169
63245986
102334155
165580141
267914296
433494437
701408733
1134903170
1836311903
2971215073
4807526976
7778742049
12586269025
20365011074
32951280099
53316291173
86267571272
139583862445
225851433717
365435296162
591286729879
956722026041
1548008755920
2504730781961
4052739537881
6557470319842
10610209857723
17167680177565
27777890035288
44945570212853
72723460248141
117669030460994
190392490709135
308061521170129
498454011879264
806515533049393
1304969544928657
2111485077978050
3416454622906707
5527939700884757
8944394323791464
14472334024676221
23416728348467685
37889062373143906
61305790721611591
99194853094755497
160500643816367088
259695496911122585
420196140727489673
679891637638612258
1100087778366101931
1779979416004714189
2880067194370816120
4660046610375530309
7540113804746346429
12200160415121876738
Kjelder
.
.
.
.
Heiltalsfølgjer
Matematiske relasjonar
Rekursjon | norwegian_nynorsk | 0.590057 |
Pony/pony_check-Poperator-.txt |
Poperator[T: T]¶
[Source]
Iterate over a Seq descructively by poping its elements.
Once has_next() returns false, the Seq is empty.
Nominee for the annual pony class-naming awards.
class ref Poperator[T: T] is
Iterator[T^] ref
Implements¶
Iterator[T^] ref
Constructors¶
create¶
[Source]
new ref create(
seq: Seq[T] ref)
: Poperator[T] ref^
Parameters¶
seq: Seq[T] ref
Returns¶
Poperator[T] ref^
empty¶
[Source]
new ref empty()
: Poperator[T] ref^
Returns¶
Poperator[T] ref^
Public Functions¶
has_next¶
[Source]
fun ref has_next()
: Bool val
Returns¶
Bool val
next¶
[Source]
fun ref next()
: T^ ?
Returns¶
T^ ?
| pony | 604454 | https://no.wikipedia.org/wiki/T%20%28andre%20betydninger%29 | T (andre betydninger) | T er den tyvende bokstaven i det latinske alfabetet, se T.
Det finnes også en kyrillisk og en gresk bokstav av samme utseende, for den kyrilliske, se Т, for den greske, se Tau (bokstav).
Bruk
T-benstek , skiver av oksekjøtt med ben
T-skjorte, et klesplagg
Transperson, et paraplybegrep som omfatter alle kjønnsoverskridere
Vitenskap og matematikk
Students t-fordeling, en statistisk term
T er symbolet for SI-prefikset tera
T er symbolet for tesla i SI-systemet
t er et symbol for en time
t er et symbol for et tonn
Transport
T-bane, for tunnelbane, kalles også undergrunn eller metro
Ford Model T, en bilmodell produsert 1908-1927 | norwegian_bokmål | 1.086616 |
Pony/collections-Reverse-.txt |
Reverse[optional A: (Real[A] val & (I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val | F32 val | F64 val))]¶
[Source]
Produces a decreasing range [max, min] with step dec, for any Number type.
(i.e. the reverse of Range)
Example program:
use "collections"
actor Main
new create(env: Env) =>
for e in Reverse(10, 2, 2) do
env.out.print(e.string())
end
Which outputs:
10
8
6
4
2
If dec is 0, produces an infinite series of max.
If dec is negative, produces a range with max as the only value.
class ref Reverse[optional A: (Real[A] val & (I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val | F32 val |
F64 val))] is
Iterator[A] ref
Implements¶
Iterator[A] ref
Constructors¶
create¶
[Source]
new ref create(
max: A,
min: A,
dec: A = 1)
: Reverse[A] ref^
Parameters¶
max: A
min: A
dec: A = 1
Returns¶
Reverse[A] ref^
Public Functions¶
has_next¶
[Source]
fun box has_next()
: Bool val
Returns¶
Bool val
next¶
[Source]
fun ref next()
: A
Returns¶
A
rewind¶
[Source]
fun ref rewind()
: None val
Returns¶
None val
| pony | 1246708 | https://no.wikipedia.org/wiki/Liste%20over%20episoder%20av%20Once%20Upon%20a%20Time | Liste over episoder av Once Upon a Time |
Oversikt
{| class="wikitable" style="text-align: center;"
|-
!style="padding: 0 8px;" colspan="2" rowspan="2"|Sesong
!style="padding: 0 8px;" rowspan="2"|Episoder
!colspan="2"|Sendt
!colspan="3"|DVD og Blu-ray-utgivelse
|-
!style="padding: 0 8px;"|Sesongpremière
!style="padding: 0 8px;"|Sesongfinale
!Region 1
!Region 2
!Region 4
|-
|style="background:#283f70; color:#FFFFFF;"|
|1
|22
|
|style="padding: 0 8px;"|
|style="padding: 0 8px;"|
|
|style="padding: 0 8px;"|
|-
|style="background:#660099; color:#FFFFFF;"|
|2
|22
|style="padding: 0 8px;"|
|
|
|style="padding: 0 8px;"|
|
|-
|style="background:#a52121; color:#FFFFFF;"|
|3
|22
|style="padding: 0 8px;"|
|
|
|
|
|-
|style="background:#16BCE6; color:#16BCE6;"|
|4
|22
|style="padding: 0 8px;"| 28. september
|
|
|
|
|}
Episoder
Sesong 1 (2011–12)
Sesong 2 (2012–13)
Sesong 3 (2013–14)
Sesong 4 (2014–15)
Once Upon a Time ble fornyet med en fjerde sesong 8. mai 2014.
Spesialepisoder
Referanser
Eksterne lenker
Once Upon a Time
Once Upon a Time | norwegian_bokmål | 0.99991 |
Pony/pony_check-ASCIIAllWithNUL-.txt |
ASCIIAllWithNUL¶
[Source]
Represents all ASCII characters,
including the NUL (\x00) character for its special treatment in C strings.
primitive val ASCIIAllWithNUL
Constructors¶
create¶
[Source]
new val create()
: ASCIIAllWithNUL val^
Returns¶
ASCIIAllWithNUL val^
Public Functions¶
apply¶
[Source]
fun box apply()
: String val
Returns¶
String val
eq¶
[Source]
fun box eq(
that: ASCIIAllWithNUL val)
: Bool val
Parameters¶
that: ASCIIAllWithNUL val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: ASCIIAllWithNUL val)
: Bool val
Parameters¶
that: ASCIIAllWithNUL val
Returns¶
Bool val
| pony | 2820009 | https://sv.wikipedia.org/wiki/Allotinus%20apus | Allotinus apus | Allotinus apus är en fjärilsart som beskrevs av De Nicéville 1895. Allotinus apus ingår i släktet Allotinus och familjen juvelvingar. Inga underarter finns listade i Catalogue of Life.
Bildgalleri
Källor
Juvelvingar
apus
en:Allotinus fallax | swedish | 1.153507 |
Pony/pony_bench-AsyncBenchContinue-.txt |
AsyncBenchContinue¶
[Source]
class val AsyncBenchContinue
Public Functions¶
complete¶
[Source]
fun box complete()
: None val
Returns¶
None val
fail¶
[Source]
fun box fail()
: None val
Returns¶
None val
| pony | 2092715 | https://no.wikipedia.org/wiki/Tegneserie%C3%A5ret%201909 | Tegneserieåret 1909 | Tegneserieåret 1909 er en oversikt over hendelser, fødte og avdøde personer med tilknytning til tegneserier i 1909.
Fødsler
|-
| Oktober || 26. || Dante Quinterno || || tegneserietegner (Patoruzú) || align=center|93 || align=center|2003 ||
|}
Referanser
Eksterne lenker | norwegian_bokmål | 1.305992 |
Pony/src-time-nanos-.txt |
nanos.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25primitive Nanos
"""
Collection of utility functions for converting various durations of time
to nanoseconds, for passing to other functions in the time package.
"""
fun from_seconds(t: U64): U64 =>
t * 1_000_000_000
fun from_millis(t: U64): U64 =>
t * 1_000_000
fun from_micros(t: U64): U64 =>
t * 1_000
fun from_seconds_f(t: F64): U64 =>
(t * 1_000_000_000).trunc().u64()
fun from_millis_f(t: F64): U64 =>
(t * 1_000_000).trunc().u64()
fun from_micros_f(t: F64): U64 =>
(t * 1_000).trunc().u64()
fun from_wall_clock(wall: (I64, I64)): U64 =>
((wall._1 * 1000000000) + wall._2).u64()
| pony | 3950206 | https://sv.wikipedia.org/wiki/Mycket%20h%C3%B6gt%20sammansatt%20tal | Mycket högt sammansatt tal | Inom matematiken är ett mycket högt sammansatt tal att naturligt tal n för vilket det finns ett positivt reellt tal ε sådant att för alla naturliga tal k större än 1 är
där d(n) är delarantalet av n.
De första mycket högt sammansatta talen är:
2, 6, 12, 60, 120, 360, 2520, 5040, 55440, 720720, 1441440, 4324320, 21621600, 367567200, 6983776800, 13967553600, 321253732800, 2248776129600, 65214507758400, 195643523275200, 6064949221531200, …
Källor
Srinivasa Ramanujan, Highly Composite Numbers, Proc. London Math. Soc. 14, 347-407, 1915; reprinted in Collected Papers (Ed. G. H. Hardy et al.), New York: Chelsea, pp. 78–129, 1962
Externa länkar
Heltalsmängder
Sigmafunktionen | swedish | 1.163057 |
Pony/c-abi.txt | # C ABI
The FFI support in Pony uses the C application binary interface (ABI) to interface with native code. The C ABI is a calling convention, one of many, that allow objects from different programming languages to be used together.
## Writing a C library for Pony
Writing your own C library for use by Pony is almost as easy as using existing libraries.
Let's look at a complete example of a C function we may wish to provide to Pony. Let's consider a pure Pony implementation of a [Jump Consistent Hash](https://arxiv.org/abs/1406.2294):
```pony
// Jump consistent hashing in Pony, with an inline pseudo random generator
// https://arxiv.org/abs/1406.2294
fun jch(key: U64, buckets: U32): I32 =>
var k = key
var b = I64(0)
var j = I64(0)
while j < buckets.i64() do
b = j
k = (k * 2862933555777941757) + 1
j = ((b + 1).f64() * (I64(1 << 31).f64() / ((k >> 33) + 1).f64())).i64()
end
b.i32()
```
Let's say we wish to compare the pure Pony performance to an existing C function with the following header:
```c
#ifndef __JCH_H_
#define __JCH_H_
extern "C"
{
int32_t jch_chash(uint64_t key, uint32_t num_buckets);
}
#endif
```
Note the use of `extern "C"`. If the library is built as C++ then we need to tell the compiler not to mangle the function name, otherwise, Pony won't be able to find it. For libraries built as C, this is not needed, of course.
The implementation of the previous header would be something like:
```c
#include <stdint.h>
// A fast, minimal memory, consistent hash algorithm
// https://arxiv.org/abs/1406.2294
int32_t jch_chash(uint64_t key, uint32_t num_buckets)
{
int b = -1;
uint64_t j = 0;
do {
b = j;
key = key * 2862933555777941757ULL + 1;
j = (b + 1) * ((double)(1LL << 31) / ((double)(key >> 33) + 1));
} while(j < num_buckets);
return (int32_t)b;
}
```
We need to compile the native code to a shared library. This example is for MacOS. The exact details may vary on other platforms.
```bash
clang -fPIC -Wall -Wextra -O3 -g -MM jch.c >jch.d
clang -fPIC -Wall -Wextra -O3 -g -c -o jch.o jch.c
clang -shared -lm -o libjch.dylib jch.o
```
The Pony code to use this new C library is just like the code we've already seen for using C libraries.
```pony
"""
This is an example of Pony integrating with native code via the built-in FFI
support
"""
use "lib:jch"
use "collections"
use @jch_chash[I32](hash: U64, bucket_size: U32)
actor Main
var _env: Env
new create(env: Env) =>
_env = env
let bucket_size: U32 = 1000000
_env.out.print("C implementation:")
for i in Range[U64](1, 20) do
let hash = @jch_chash(i, bucket_size)
_env.out.print(i.string() + ": " + hash.string())
end
_env.out.print("Pony implementation:")
for i in Range[U64](1, 20) do
let hash = jch(i, bucket_size)
_env.out.print(i.string() + ": " + hash.string())
end
fun jch(key: U64, buckets: U32): I32 =>
var k = key
var b = I64(0)
var j = I64(0)
while j < buckets.i64() do
b = j
k = (k * 2862933555777941757) + 1
j = ((b + 1).f64() * (I64(1 << 31).f64() / ((k >> 33) + 1).f64())).i64()
end
b.i32()
```
We can now use ponyc to compile a native executable integrating Pony and our C library. And that's all we need to do.
| pony | 3400825 | https://sv.wikipedia.org/wiki/Curranops%20apicalis | Curranops apicalis | Curranops apicalis är en tvåvingeart som först beskrevs av Cole och Jon C. Lovett 1921. Curranops apicalis ingår i släktet Curranops och familjen fläckflugor. Inga underarter finns listade i Catalogue of Life.
Källor
Fläckflugor
apicalis | swedish | 1.361288 |
Pony/pony_check-IntPairProperty-.txt |
IntPairProperty¶
[Source]
A property implementation for conveniently evaluating properties
for pairs of integers of all Pony integer types at once.
The property needs to be formulated inside the method int_property:
class CommutativeMultiplicationProperty is IntPairProperty
fun name(): String => "commutativity/mul"
fun int_property[T: (Int & Integer[T] val)](x: T, y: T, h: PropertyHelper)? =>
h.assert_eq[T](x * y, y * x)
trait ref IntPairProperty is
Property1[IntPairPropertySample ref] ref
Implements¶
Property1[IntPairPropertySample ref] ref
Public Functions¶
gen¶
[Source]
fun box gen()
: Generator[IntPairPropertySample ref] box
Returns¶
Generator[IntPairPropertySample ref] box
property¶
[Source]
fun ref property(
sample: IntPairPropertySample ref,
h: PropertyHelper val)
: None val ?
Parameters¶
sample: IntPairPropertySample ref
h: PropertyHelper val
Returns¶
None val ?
int_property[T: ((I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Integer[T] val)]¶
[Source]
fun ref int_property[T: ((I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val) & Integer[T] val)](
x: T,
y: T,
h: PropertyHelper val)
: None val ?
Parameters¶
x: T
y: T
h: PropertyHelper val
Returns¶
None val ?
name¶
fun box name()
: String val
Returns¶
String val
params¶
fun box params()
: PropertyParams val
Returns¶
PropertyParams val
| pony | 409599 | https://nn.wikipedia.org/wiki/UN-nummer | UN-nummer | UN-nummer (forkorta frå engelsk: United Nations number) er eit fire siffera nummer som identifiserer farlege materiale og gjenstandar (som sprengstoff, brennbar væske, oksidiserande, giftig væske, osfr.) i samband med internasjonal handel og transport. Somme farlege stoff har sine eige UN-nummer (til dømes akrylamid har UN 2074), medan nokre kjemikalar eller produkt med liknande eigenskapar har eit felles UN-nummer. Ein kjemikalie i fast tilstand kan ha eit anna UN-nummer enn kjemikalien i flytande form dersom eigenskapane er ymse; same stoff med ulik konsentrasjon kan òg ha ulike UN-nummer.
Regulering
Det finst ulike internasjonale regelverk og internasjonale institusjonar som tek føre seg ulike typar transportmiddel:
RID for jarnbanetrafikk
ADR-S for landtransport
ICAO-TI for luftfart
IMDG for sjøfart
Tildeling av UN-nummer
UN-nummer varierer frå UN 0004 til omtrent UN 3550 (UN 0001–UN 0003 er ikkje lenger i bruk) og er tildelt av FNs ekspertkomité for transport av farleg gods. Dei vert publisert som ein del av sine tilrådingar om transport av farleg gods, òg kjent som Orange Book. Det finst ikkje UN-nummer for ikkje-farlege stoff.
Døme på UN-nummer
Ammoniakk: 1005
Bensin: 1203
Diesel: 1202
Etanol: 1170
Klor: 1017
Metanol: 1230
Merking av transportmiddel
Landtransport
Varebilar, lastebilar og jarnbanevogner som fraktar farleg gods vert merka med oransje rektangulære skilt, ADR-skilt. Farenummer er skrive i øvre del, medan UN-nummeret i nedre del av skiltet. Dei ulike farenummera tyder:
0 – Inga betyding / Ingen sekundærfare
2 – Gass
3 – Brannfarleg væske eller gass
4 – Brannfarleg fast stoff
5 – Oksiderande
6 – Giftig
7 – Radioaktiv
8 – Etsande
9 – Risiko for ofseleg reaksjon
x – Farleg reaksjon med vatn
Døme på kombinerte farenummer:
20 – Kvelande gass eller gass utan tilleggsrisiko
22 – Nedkjølt flytande gass, kvelande
23 – Brennbar gass
268 – Giftig gass, etsande
30 – Brannfarleg væske
336 – særleg brannfarleg væske, giftig
80 – Etsande eller veikt etsande stoff
Når to like farenummer er skrive etter kvarandre viser det til ein forsterka fare. Til dømes tyder 33 at noko er ekstra brannfarleg, og 88 for særleg etsande stoff.
Andre identifiseringsnummer
Eit NA-nummer (North America number) vert tildelt av det amerikanske transportdepartementet og er identisk med UN-nummer med somme unntak. Til dømes, NA 3334, er sjølvforsvarspray, medan UN 3334 er væske som er regulert til luftfart. Visse stoff som ikkje har eit UN-nummer kan likevel ha eit NA-nummer. Desse unntaka der det ikkje finst eit UN-nummer nyttar området NA 9000–NA 9279.
Eit ID-nummer er ein tredje type identifikasjonsnummer som vert nytta for farlege stoff som vert vigt til lufttransport. Stoff med ID-nummer er knytt til egna fraktnamn som er godkjend av ICAO Technical Instructions. ID 8000, Forbrukarvare har ikkje eit UN- eller NA-nummer og er klassifisert som eit farleg materiale i klasse 9.
Sjå òg
Globalt Harmonisert System for klassifisering og merking av kjemikaliar
Farleg gods
CAS-nummer
Kjelder
Denne artikkelen bygger på «UN number» frå , den 31. juli 2023.
Bakgrunnsstoff
Regelverk
«Dangerous Goods» i United Nations Economic Commission for Europe (UNECE).
«UN Recommendations on the Transport of Dangerous Goods». Del 2 definerer fareklasser og del 3 inneheld ein fullstendig liste over alle UN-nummer og fareidentifikatorar.
Merking av køyretøy
«Hazard Identification Number Placard i International Labour Organization.
«Farlig gods» i brannteori.no
«Informasjon om farlig gods: Merking» ved direktoratet for samfunnssikkerhet og beredskap.
Liste over alle NA-nummer saman med tryggingsprosedyrar. The Emergency Response Guidebook frå U.S. Department of Transportation.
NA- og UN-nummer databasesøk
Farlig gods-permen UN-nummersøk og andre verktøy i dsb.no
Cameo Chemicals både NA- og UN-nummersøk.
Kjemisk nummerering | norwegian_nynorsk | 1.335855 |
Pony/builtin-Less-.txt |
Less¶
[Source]
primitive val Less is
Equatable[(Less val | Equal val | Greater val)] ref
Implements¶
Equatable[(Less val | Equal val | Greater val)] ref
Constructors¶
create¶
[Source]
new val create()
: Less val^
Returns¶
Less val^
Public Functions¶
string¶
[Source]
fun box string()
: String iso^
Returns¶
String iso^
eq¶
[Source]
fun box eq(
that: (Less val | Equal val | Greater val))
: Bool val
Parameters¶
that: (Less val | Equal val | Greater val)
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: (Less val | Equal val | Greater val))
: Bool val
Parameters¶
that: (Less val | Equal val | Greater val)
Returns¶
Bool val
| pony | 2140886 | https://sv.wikipedia.org/wiki/Eobrolgus | Eobrolgus | Eobrolgus är ett släkte av kräftdjur. Eobrolgus ingår i familjen Phoxocephalidae.
Kladogram enligt Catalogue of Life:
Källor
Externa länkar
Märlkräftor
Eobrolgus | swedish | 1.040858 |
Pony/collections-persistent-Nil-.txt |
Nil[A: A]¶
[Source]
The empty list of As.
primitive val Nil[A: A] is
ReadSeq[val->A] box
Implements¶
ReadSeq[val->A] box
Constructors¶
create¶
[Source]
new val create()
: Nil[A] val^
Returns¶
Nil[A] val^
Public Functions¶
size¶
[Source]
Returns the size of the list.
fun box size()
: USize val
Returns¶
USize val
apply¶
[Source]
Returns the i-th element of the sequence. For the empty list this call will
always error because any index will be out of bounds.
fun box apply(
i: USize val)
: val->A ?
Parameters¶
i: USize val
Returns¶
val->A ?
values¶
[Source]
Returns an empty iterator over the elements of the empty list.
fun box values()
: Iterator[val->A] ref^
Returns¶
Iterator[val->A] ref^
is_empty¶
[Source]
Returns a Bool indicating if the list is empty.
fun box is_empty()
: Bool val
Returns¶
Bool val
is_non_empty¶
[Source]
Returns a Bool indicating if the list is non-empty.
fun box is_non_empty()
: Bool val
Returns¶
Bool val
head¶
[Source]
Returns an error, since Nil has no head.
fun box head()
: val->A ?
Returns¶
val->A ?
tail¶
[Source]
Returns an error, since Nil has no tail.
fun box tail()
: (Cons[A] val | Nil[A] val) ?
Returns¶
(Cons[A] val | Nil[A] val) ?
reverse¶
[Source]
The reverse of the empty list is the empty list.
fun box reverse()
: Nil[A] val
Returns¶
Nil[A] val
prepend¶
[Source]
Builds a new list with an element added to the front of this list.
fun box prepend(
a: val->A!)
: Cons[A] val
Parameters¶
a: val->A!
Returns¶
Cons[A] val
concat¶
[Source]
The concatenation of any list l with the empty list is l.
fun box concat(
l: (Cons[A] val | Nil[A] val))
: (Cons[A] val | Nil[A] val)
Parameters¶
l: (Cons[A] val | Nil[A] val)
Returns¶
(Cons[A] val | Nil[A] val)
map[B: B]¶
[Source]
Mapping a function from A to B over the empty list yields the
empty list of Bs.
fun box map[B: B](
f: {(val->A): val->B}[A, B] box)
: Nil[B] val
Parameters¶
f: {(val->A): val->B}[A, B] box
Returns¶
Nil[B] val
flat_map[B: B]¶
[Source]
Flatmapping a function from A to B over the empty list yields the
empty list of Bs.
fun box flat_map[B: B](
f: {(val->A): List[B]}[A, B] box)
: Nil[B] val
Parameters¶
f: {(val->A): List[B]}[A, B] box
Returns¶
Nil[B] val
for_each¶
[Source]
Applying a function to every member of the empty list is a no-op.
fun box for_each(
f: {(val->A)}[A] box)
: None val
Parameters¶
f: {(val->A)}[A] box
Returns¶
None val
filter¶
[Source]
Filtering the empty list yields the empty list.
fun box filter(
f: {(val->A): Bool}[A] box)
: Nil[A] val
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
Nil[A] val
fold[B: B]¶
[Source]
Folding over the empty list yields the initial accumulator.
fun box fold[B: B](
f: {(B, val->A): B^}[A, B] box,
acc: B)
: B
Parameters¶
f: {(B, val->A): B^}[A, B] box
acc: B
Returns¶
B
every¶
[Source]
Any predicate is true of every member of the empty list.
fun box every(
f: {(val->A): Bool}[A] box)
: Bool val
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
Bool val
exists¶
[Source]
For any predicate, there is no element that satisfies it in the empty
list.
fun box exists(
f: {(val->A): Bool}[A] box)
: Bool val
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
Bool val
partition¶
[Source]
The only partition of the empty list is two empty lists.
fun box partition(
f: {(val->A): Bool}[A] box)
: (Nil[A] val , Nil[A] val)
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
(Nil[A] val , Nil[A] val)
drop¶
[Source]
There are no elements to drop from the empty list.
fun box drop(
n: USize val)
: Nil[A] val
Parameters¶
n: USize val
Returns¶
Nil[A] val
drop_while¶
[Source]
There are no elements to drop from the empty list.
fun box drop_while(
f: {(val->A): Bool}[A] box)
: Nil[A] val
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
Nil[A] val
take¶
[Source]
There are no elements to take from the empty list.
fun box take(
n: USize val)
: Nil[A] val
Parameters¶
n: USize val
Returns¶
Nil[A] val
take_while¶
[Source]
There are no elements to take from the empty list.
fun box take_while(
f: {(val->A): Bool}[A] box)
: Nil[A] val
Parameters¶
f: {(val->A): Bool}[A] box
Returns¶
Nil[A] val
contains[optional T: (A & HasEq[A!] #read)]¶
[Source]
fun val contains[optional T: (A & HasEq[A!] #read)](
a: val->T)
: Bool val
Parameters¶
a: val->T
Returns¶
Bool val
eq¶
[Source]
fun box eq(
that: Nil[A] val)
: Bool val
Parameters¶
that: Nil[A] val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: Nil[A] val)
: Bool val
Parameters¶
that: Nil[A] val
Returns¶
Bool val
| pony | 2849747 | https://sv.wikipedia.org/wiki/Aurivillius%20arata | Aurivillius arata | Aurivillius arata är en fjärilsart som beskrevs av John Obadiah Westwood 1849. Aurivillius arata ingår i släktet Aurivillius och familjen påfågelsspinnare. Inga underarter finns listade i Catalogue of Life.
Källor
Externa länkar
Påfågelsspinnare
arata | swedish | 1.185502 |
Pony/src-builtin-iterator-.txt |
iterator.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86interface Iterator[A]
"""
Iterators generate a series of values, one value at a time on each call to `next()`.
An Iterator is considered exhausted, once its `has_next()` method returns `false`.
Thus every call to `next()` should be preceeded with a call to `has_next()` to
check for exhaustiveness.
## Usage
Given the rules for using Iterators mentioned above, basic usage
of an iterator looks like this:
```pony
while iterator.has_next() do
let elem = iterator.next()?
// do something with elem
end
```
The `For`-loop provides a more concise way of iteration:
```pony
for elem in iterator do
// do something with elem
end
```
Iteration using `While` is more flexible as it allows to continue iterating if a call to `next()` errors.
The `For`-loop does not allow this.
## Implementing Iterators
Iterator implementations need to adhere to the following rules to be considered well-behaved:
* If the Iterator is exhausted, `has_next()` needs to return `false`.
* Once `has_next()` returned `false` it is not allowed to switch back to `true`
(Unless the Iterator supports rewinding)
* `has_next()` does not change its returned value if `next()` has not been called.
That means, that between two calls to `next()` any number of calls to `has_next()`
need to return the same value. (Unless the Iterator supports rewinding)
* A call to `next()` erroring does not necessarily denote exhaustiveness.
### Example
```pony
// Generates values from `from` to 0
class ref Countdown is Iterator[USize]
var _cur: USize
var _has_next: Bool = true
new ref create(from: USize) =>
_cur = from
fun ref has_next(): Bool =>
_has_next
fun ref next(): USize =>
let elem = _cur = _cur - 1
if elem == 0 then
_has_next = false
end
elem
```
"""
fun ref has_next(): Bool
"""
Returns `true` if this Iterator is not yet exhausted.
That means that a value returned from a subsequent call to `next()`
is a valid part of this iterator.
Returns `false` if this Iterator is exhausted.
The behavior of `next()` after this function returned `false` is undefined,
it might throw an error or return values which are not part of this Iterator.
"""
fun ref next(): A ?
"""
Generate the next value.
This might error, which does not necessarily mean that the Iterator is exhausted.
"""
| pony | 1370634 | https://no.wikipedia.org/wiki/Nexus%206P | Nexus 6P | Nexus 6P (kodenavn Angler) er en smarttelefon laget av Huawei. Den er utviklet i samarbeid med Google, og er en del av Nexus-serien. Den ble vist frem 29. september 2015 sammen med Nexus 5X. Produksjonen av Nexus 6P ble avsluttet 4. oktober 2016. Nexus 6P er etterkommeren til Nexus 6, og har nå en fingeravtrykkssensor, en raskere CPU, større skjerm og bedre kameraer, men ikke muligheten til trådløs lading.
Spesifikasjoner
Maskinvare
Nexus 6P har en Snapdragon 810 v2.1-prosessor med 3 GB RAM, og enten 32, 64 eller 128 GB intern lagring. Batteriet har en kapasitet på 3450 mAh, med en USB-C-inngang for lading og dataoverføring. Kameramodulene blir laget av Sony (Sony ExmorR IMX 377). Det bakovervendte kameraet har 12.3 megapiksler, med en apertur på f/2.0 og et autofokus-system som bruker IR-lasere. Det kan filme i 4K, samt sakte film ved 720p@240fps. Frontkameraet har 8 megapiksler og en apertur på f/2.4.
Fingeravtrykkssensoren, med navnet Nexus Imprint er ved midten av enheten, under kameraet. Skjermen er en 5,7-tommers WQHD AMOLED-skjerm, med en oppløsning på 2,560 x 1,440 piksler (518 ppi).
Programvare
Telefonen kjører Android versjon 6.0 «Marshmallow». Kan oppgraderes til Android versjon 8.1 «Oreo».
Design
Telefonen er den første i Nexus-serien laget i en metallkropp. Fargevalgene er aluminium, grafitt, frost og gull (ekslusivt for Japan).
Referanser
Eksterne lenker
Mobiltelefoner
Huawei
Google-maskinvare | norwegian_bokmål | 1.324451 |
Pony/files-FileBadFileNumber-.txt |
FileBadFileNumber¶
[Source]
primitive val FileBadFileNumber
Constructors¶
create¶
[Source]
new val create()
: FileBadFileNumber val^
Returns¶
FileBadFileNumber val^
Public Functions¶
eq¶
[Source]
fun box eq(
that: FileBadFileNumber val)
: Bool val
Parameters¶
that: FileBadFileNumber val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FileBadFileNumber val)
: Bool val
Parameters¶
that: FileBadFileNumber val
Returns¶
Bool val
| pony | 1010891 | https://da.wikipedia.org/wiki/OpenQASM | OpenQASM | Open Quantum Assembly Language (OpenQASM; udtales open kazm) er en mellemkode for kvanteinstruktioner. Sproget blev først beskrevet i en artikel offentliggjort i juli 2017, og kildekode blev frigjort som en del af IBMs Quantum Information Software Kit (Qiskit) til anvendelse af deres IBM Q Experience cloud kvantedatabehandlingsplatform. Sproget har ligheder med traditionel hardware beskrivelsessprog såsom Verilog.
Eksempler
Det følgende er et eksempel på OpenQASM kildekode fra det officielle bibliotek. Programmet adderer to fire-bit tal sammen.
// quantum ripple-carry adder from Cuccaro et al, quant-ph/0410184
OPENQASM 2.0;
include "qelib1.inc";
gate majority a,b,c
{
cx c,b;
cx c,a;
ccx a,b,c;
}
gate unmaj a,b,c
{
ccx a,b,c;
cx c,a;
cx a,b;
}
qreg cin[1];
qreg a[4];
qreg b[4];
qreg cout[1];
creg ans[5];
// set input states
x a[0]; // a = 0001
x b; // b = 1111
// add a to b, storing result in b
majority cin[0],b[0],a[0];
majority a[0],b[1],a[1];
majority a[1],b[2],a[2];
majority a[2],b[3],a[3];
cx a[3],cout[0];
unmaj a[2],b[3],a[3];
unmaj a[1],b[2],a[2];
unmaj a[0],b[1],a[1];
unmaj cin[0],b[0],a[0];
measure b[0] -> ans[0];
measure b[1] -> ans[1];
measure b[2] -> ans[2];
measure b[3] -> ans[3];
measure cout[0] -> ans[4];
Kilder/referencer
Eksterne henvisninger
OpenQASM on GitHub
Programmeringssprog
Kvantedatabehandling
Kvanteinformatik | danish | 1.07002 |
Pony/process-Signaled-.txt |
Signaled¶
[Source]
Process exit status: Process was terminated by a signal.
class val Signaled is
Stringable box,
Equatable[(Exited val | Signaled val)] ref
Implements¶
Stringable box
Equatable[(Exited val | Signaled val)] ref
Constructors¶
create¶
[Source]
new val create(
sig: U32 val)
: Signaled val^
Parameters¶
sig: U32 val
Returns¶
Signaled val^
Public Functions¶
signal¶
[Source]
Retrieve the signal number that exited the process.
fun box signal()
: U32 val
Returns¶
U32 val
string¶
[Source]
fun box string()
: String iso^
Returns¶
String iso^
eq¶
[Source]
fun box eq(
other: (Exited val | Signaled val))
: Bool val
Parameters¶
other: (Exited val | Signaled val)
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: (Exited val | Signaled val))
: Bool val
Parameters¶
that: (Exited val | Signaled val)
Returns¶
Bool val
| pony | 46866 | https://sv.wikipedia.org/wiki/VHDL | VHDL | VHDL, VHSIC (Very High Speed Integrated Circuit) Hardware Description Language, är ett hårdvarubeskrivande språk, vilket betyder att det liksom Verilog är ett programspråk som används för att beskriva digitala kretsar som sedan kan realiseras i en grindmatris eller ASIC.
VHDL lånar många element i sin syntax från Ada.
Historia
VHDL utvecklades 1980 av IBM, Texas Instruments och Intermetrics kontrakterade av det amerikanska försvaret. VHDL har kommit ut i ett antal nya versioner sen dess och idag vidareutvecklas programspråket under IEEE Computer Society som en IEEE standard.
VHDL Analysis and Standards Group (http://www.eda.org/vasg/ [VASG]) håller i den utvecklingen.
Programexempel
En krets, till exempel en vippa, kallas i programspråket för en entitet. En sådan beskrivs av dess portar, dvs in- och utgångar som den använder för att kommunicera med andra kretsar, samt sin funktion, i språket kallat sitt beteende (behaviour), dvs vad den beroende på sina insignaler skickar ut som utsignal.
Beteendet hos en entitet styrs av processer som triggar på en av insignalernas positiva eller negativa flank.
D-vippa
Följande exempel är en D-vippa med synkroniserad reset som sparar en databit:
-- VHDL exempel program: DFlipFlop.vhd
-- en kommentar inleds med dubbla streck
library IEEE; -- motsvarande C++: #include <...>
use IEEE.std_logic_1164.all; -- motsvarande C++: using namespace ...
entity DFlipFlop is -- moduldeklaration (C++: klassdeklaration)
port ( -- port(...) deklarerar alla "publika" signaler
CLK : in STD_LOGIC; -- ingång CLK
RST : in STD_LOGIC; -- ingång RST, aktiv hög
D : in STD_LOGIC; -- ingång D - värdet som skall "kopieras"
Q : out STD_LOGIC -- utgång Q - det kopierade värdet
);
end DFlipFlop;
architecture behaviour of DFlipFlop is -- motsvarande en klassdefinition.
-- här deklareras ev. "privata" signaler/funktioner
begin
process(CLK) -- processen "körs" när CLK ändras...
begin
if rising_edge(CLK) then --...från nolla till etta
if RST = '1' then -- Om RST är aktiv (hög), så skall vi...
Q <= '0'; --...nollställa utgången...
else --...annars skall vi...
Q <= D; --...kopiera värdet på ingången D
end if;
end if; -- Kom ihåg: Raderna ovan händer bara när CLK går från 0 till 1.
end process;
end behaviour; -- Avsluta "klassdeklarationen".
Se även
ASIC
FPGA
Grindmatris
Verilog
Externa länkar
Öppen källkod VHDL simulator
Programspråk
Hårdvarubeskrivande språk
Datorteknik
Elektronik
Digitalteknik | swedish | 0.916654 |
Pony/builtin-Any-.txt |
Any¶
[Source]
interface tag Any
| pony | 282185 | https://sv.wikipedia.org/wiki/Disassemblator | Disassemblator | Disassemblator, eller disassemblerare, är ett program som analyserar en kompilerad fil och reproducerar källkoden för filen i assemblerkod.
Lista på Disassemblatorer (inte komplett)
IDA Pro - Kommersiell, interaktiv disassemblerare med möjligheter att bl.a. återvisa kod i strukturerade grafer.
BORG Disassembler
RosAsm - 32 bit Assembler
Sourcer
The Bastard Disassembler - En kommandobaserad disassemblator för Linux.
DASMx
PVDasm
HT Editor
Udis86
diStorm64
PostSharp
OllyDbg
ChARMeD Disassembler - Disassemblerare för Windows Mobile, Pocket PC och Windows CE.
Win32 Program disassembler - Disassemblator för PE-formatet.
BIEW - Binary vIEW project.
Externa länkar
transformation Wiki on disassembly
OpenRCE: Various Disassembler Resources and Plug-ins
The free country
Programmer's heaven
Datorprogram för programutveckling | swedish | 1.160957 |
Pony/files-FileRename-.txt |
FileRename¶
[Source]
primitive val FileRename
Constructors¶
create¶
[Source]
new val create()
: FileRename val^
Returns¶
FileRename val^
Public Functions¶
value¶
[Source]
fun box value()
: U32 val
Returns¶
U32 val
eq¶
[Source]
fun box eq(
that: FileRename val)
: Bool val
Parameters¶
that: FileRename val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FileRename val)
: Bool val
Parameters¶
that: FileRename val
Returns¶
Bool val
| pony | 3268212 | https://sv.wikipedia.org/wiki/Villa%20nebulo | Villa nebulo | Villa nebulo är en tvåvingeart som först beskrevs av Daniel William Coquillett 1887. Villa nebulo ingår i släktet Villa och familjen svävflugor. Inga underarter finns listade i Catalogue of Life.
Källor
Svävflugor
nebulo | swedish | 1.204346 |
Pony/src-builtin-string-.txt |
string.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757use @memcmp[I32](dst: Pointer[None] tag, src: Pointer[None] tag, len: USize)
use @memset[Pointer[None]](dst: Pointer[None], set: U32, len: USize)
use @memmove[Pointer[None]](dst: Pointer[None], src: Pointer[None], len: USize)
use @strtof[F32](nptr: Pointer[U8] tag, endptr: Pointer[Pointer[U8] box] ref)
use @strtod[F64](nptr: Pointer[U8] tag, endptr: Pointer[Pointer[U8] box] ref)
use @pony_os_clear_errno[None]()
use @pony_os_errno[I32]()
class val String is (Seq[U8] & Comparable[String box] & Stringable)
"""
A String is an ordered collection of bytes.
Strings don't specify an encoding.
Example usage of some common String methods:
```pony
actor Main
new create(env: Env) =>
try
// construct a new string
let str = "Hello"
// make an uppercased version
let str_upper = str.upper()
// make a reversed version
let str_reversed = str.reverse()
// add " world" to the end of our original string
let str_new = str.add(" world")
// count occurrences of letter "l"
let count = str_new.count("l")
// find first occurrence of letter "w"
let first_w = str_new.find("w") ?
// find first occurrence of letter "d"
let first_d = str_new.find("d") ?
// get substring capturing "world"
let substr = str_new.substring(first_w, first_d+1)
// clone substring
let substr_clone = substr.clone()
// print our substr
env.out.print(consume substr)
end
```
"""
var _size: USize
var _alloc: USize
var _ptr: Pointer[U8]
new create(len: USize = 0) =>
"""
An empty string. Enough space for len bytes is reserved.
"""
_size = 0
_alloc = len.min(len.max_value() - 1) + 1
_ptr = Pointer[U8]._alloc(_alloc)
_set(0, 0)
new val from_array(data: Array[U8] val) =>
"""
Create a string from an array, reusing the underlying data pointer.
"""
_size = data.size()
_alloc = data.space()
_ptr = data.cpointer()._unsafe()
new iso from_iso_array(data: Array[U8] iso) =>
"""
Create a string from an array, reusing the underlying data pointer
"""
_size = data.size()
_alloc = data.space()
_ptr = (consume data).cpointer()._unsafe()
if _alloc > _size then
_set(_size, 0)
end
new from_cpointer(str: Pointer[U8], len: USize, alloc: USize = 0) =>
"""
Return a string from binary pointer data without making a
copy. This must be done only with C-FFI functions that return
pony_alloc'd character arrays. If a null pointer is given then an
empty string is returned.
"""
if str.is_null() then
_size = 0
_alloc = 1
_ptr = Pointer[U8]._alloc(_alloc)
_set(0, 0)
else
_size = len
_alloc = alloc.max(_size.min(len.max_value() - 1))
_ptr = str
end
new from_cstring(str: Pointer[U8]) =>
"""
Return a string from a pointer to a null-terminated cstring
without making a copy. The data is not copied. This must be done
only with C-FFI functions that return pony_alloc'd character
arrays. The pointer is scanned for the first null byte, which will
be interpreted as the null terminator. Note that the scan is
unbounded; the pointed to data must be null-terminated within
the allocated array to preserve memory safety. If a null pointer
is given then an empty string is returned.
"""
if str.is_null() then
_size = 0
_alloc = 1
_ptr = Pointer[U8]._alloc(_alloc)
_set(0, 0)
else
var i: USize = 0
while str._apply(i) != 0 do
i = i + 1
end
_size = i
_alloc = i + 1
_ptr = str
end
new copy_cpointer(str: Pointer[U8] box, len: USize) =>
"""
Create a string by copying a fixed number of bytes from a pointer.
"""
if str.is_null() then
_size = 0
_alloc = 1
_ptr = Pointer[U8]._alloc(_alloc)
_set(0, 0)
else
_size = len
_alloc = _size + 1
_ptr = Pointer[U8]._alloc(_alloc)
str._copy_to(_ptr, _alloc)
end
new copy_cstring(str: Pointer[U8] box) =>
"""
Create a string by copying a null-terminated C string. Note that
the scan is unbounded; the pointed to data must be null-terminated
within the allocated array to preserve memory safety. If a null
pointer is given then an empty string is returned.
"""
if str.is_null() then
_size = 0
_alloc = 1
_ptr = Pointer[U8]._alloc(_alloc)
_set(0, 0)
else
var i: USize = 0
while str._apply(i) != 0 do
i = i + 1
end
_size = i
_alloc = i + 1
_ptr = Pointer[U8]._alloc(_alloc)
str._copy_to(_ptr, _alloc)
end
new from_utf32(value: U32) =>
"""
Create a UTF-8 string from a single UTF-32 code point.
"""
let encoded = _UTF32Encoder.encode(value)
_size = encoded._1
_alloc = _size + 1
_ptr = Pointer[U8]._alloc(_alloc)
_set(0, encoded._2)
if encoded._1 > 1 then
_set(1, encoded._3)
if encoded._1 > 2 then
_set(2, encoded._4)
if encoded._1 > 3 then
_set(3, encoded._5)
end
end
end
_set(_size, 0)
fun ref push_utf32(value: U32) =>
"""
Push a UTF-32 code point.
"""
let encoded = _UTF32Encoder.encode(value)
let i = _size
_size = _size + encoded._1
reserve(_size)
_set(i, encoded._2)
if encoded._1 > 1 then
_set(i + 1, encoded._3)
if encoded._1 > 2 then
_set(i + 2, encoded._4)
if encoded._1 > 3 then
_set(i + 3, encoded._5)
end
end
end
_set(_size, 0)
fun _copy_to(ptr: Pointer[U8] ref, copy_len: USize,
from_offset: USize = 0, to_offset: USize = 0) =>
"""
Copy `copy_len` bytes from this to that at specified offsets.
"""
_ptr._offset(from_offset)._copy_to(ptr._offset(to_offset), copy_len)
fun cpointer(offset: USize = 0): Pointer[U8] tag =>
"""
Returns a C compatible pointer to the underlying string allocation.
"""
_ptr._offset(offset)
fun cstring(): Pointer[U8] tag =>
"""
Returns a C compatible pointer to a null-terminated version of the
string, safe to pass to an FFI function that doesn't accept a size
argument, expecting a null-terminator. If the underlying string
is already null terminated, this is returned; otherwise the string
is copied into a new, null-terminated allocation.
"""
if is_null_terminated() then
return _ptr
end
let ptr = Pointer[U8]._alloc(_size + 1)
_ptr._copy_to(ptr._unsafe(), _size)
ptr._update(_size, 0)
ptr
fun val array(): Array[U8] val =>
"""
Returns an Array[U8] that reuses the underlying data pointer.
"""
recover
Array[U8].from_cpointer(_ptr._unsafe(), _size, _alloc)
end
fun iso iso_array(): Array[U8] iso^ =>
"""
Returns an Array[U8] iso that reuses the underlying data pointer.
"""
recover
Array[U8].from_cpointer(_ptr._unsafe(), _size, _alloc)
end
fun size(): USize =>
"""
Returns the length of the string data in bytes.
"""
_size
fun codepoints(from: ISize = 0, to: ISize = ISize.max_value()): USize =>
"""
Returns the number of unicode code points in the string between the two
offsets. Index range [`from` .. `to`) is half-open.
"""
if _size == 0 then
return 0
end
var i = offset_to_index(from)
let j = offset_to_index(to).min(_size)
var n = USize(0)
while i < j do
if (_ptr._apply(i) and 0xC0) != 0x80 then
n = n + 1
end
i = i + 1
end
n
fun space(): USize =>
"""
Returns the space available for data, not including the null terminator.
"""
if is_null_terminated() then _alloc - 1 else _alloc end
fun ref reserve(len: USize) =>
"""
Reserve space for len bytes. An additional byte will be reserved for the
null terminator.
"""
if _alloc <= len then
let max = len.max_value() - 1
let min_alloc = len.min(max) + 1
if min_alloc <= (max / 2) then
_alloc = min_alloc.next_pow2()
else
_alloc = min_alloc.min(max)
end
_ptr = _ptr._realloc(_alloc, _size)
end
fun ref compact() =>
"""
Try to remove unused space, making it available for garbage collection. The
request may be ignored. The string is returned to allow call chaining.
"""
if (_size + 1) <= 512 then
if (_size + 1).next_pow2() != _alloc.next_pow2() then
_alloc = (_size + 1).next_pow2()
let old_ptr = _ptr = Pointer[U8]._alloc(_alloc)
old_ptr._copy_to(_ptr, _size)
_set(_size, 0)
end
elseif (_size + 1) < _alloc then
_alloc = (_size + 1)
let old_ptr = _ptr = Pointer[U8]._alloc(_alloc)
old_ptr._copy_to(_ptr, _size)
_set(_size, 0)
end
fun ref recalc() =>
"""
Recalculates the string length. This is only needed if the string is
changed via an FFI call. If a null terminator byte is not found within the
allocated length, the size will not be changed.
"""
var s: USize = 0
while (s < _alloc) and (_ptr._apply(s) > 0) do
s = s + 1
end
if s != _alloc then
_size = s
end
fun ref truncate(len: USize) =>
"""
Truncates the string at the minimum of len and space. Ensures there is a
null terminator. Does not check for null terminators inside the string.
Note that memory is not freed by this operation.
"""
if len >= _alloc then
_size = len.min(_alloc)
reserve(_alloc + 1)
else
_size = len.min(_alloc - 1)
end
_set(_size, 0)
fun ref trim_in_place(from: USize = 0, to: USize = -1) =>
"""
Trim the string to a portion of itself, covering `from` until `to`.
Unlike slice, the operation does not allocate a new string nor copy
elements.
"""
let last = _size.min(to)
let offset = last.min(from)
let size' = last - offset
// use the new size' for alloc if we're not including the last used byte
// from the original data and only include the extra allocated bytes if
// we're including the last byte.
_alloc = if last == _size then _alloc - offset else size' end
_size = size'
// if _alloc == 0 then we've trimmed all the memory originally allocated.
// if we do _ptr._offset, we will spill into memory not allocated/owned
// by this string and could potentially cause a segfault if we cross
// a pagemap boundary into a pagemap address that hasn't been allocated
// yet when `reserve` is called next.
if _alloc == 0 then
_ptr = Pointer[U8]
else
_ptr = _ptr._offset(offset)
end
fun val trim(from: USize = 0, to: USize = -1): String val =>
"""
Return a shared portion of this string, covering `from` until `to`.
Both the original and the new string are immutable, as they share memory.
The operation does not allocate a new string pointer nor copy elements.
"""
let last = _size.min(to)
let offset = last.min(from)
recover
let size' = last - offset
// use the new size' for alloc if we're not including the last used byte
// from the original data and only include the extra allocated bytes if
// we're including the last byte.
let alloc = if last == _size then _alloc - offset else size' end
if size' > 0 then
from_cpointer(_ptr._offset(offset)._unsafe(), size', alloc)
else
create()
end
end
fun iso chop(split_point: USize): (String iso^, String iso^) =>
"""
Chops the string in half at the split point requested and returns both
the left and right portions. The original string is trimmed in place and
returned as the left portion. If the split point is larger than the
string, the left portion is the original string and the right portion
is a new empty string.
Both strings are isolated and mutable, as they do not share memory.
The operation does not allocate a new string pointer nor copy elements.
"""
let start_ptr = cpointer(split_point)
let size' = _size - _size.min(split_point)
let alloc = _alloc - _size.min(split_point)
trim_in_place(0, split_point)
let right = recover
if size' > 0 then
from_cpointer(start_ptr._unsafe(), size', alloc)
else
create()
end
end
(consume this, consume right)
fun iso unchop(b: String iso): ((String iso^, String iso^) | String iso^) =>
"""
Unchops two iso strings to return the original string they were chopped
from. Both input strings are isolated and mutable and were originally
chopped from a single string. This function checks that they are indeed two
strings chopped from the same original string and can be unchopped before
doing the unchopping and returning the unchopped string. If the two strings
cannot be unchopped it returns both strings without modifying them.
The operation does not allocate a new string pointer nor copy elements.
"""
if _size == 0 then
return consume b
end
if b.size() == 0 then
return consume this
end
(let unchoppable, let a_left) =
if (_size == _alloc) and (cpointer(_size) == b.cpointer()) then
(true, true)
elseif (b.size() == b.space()) and (b.cpointer(b.size()) == cpointer())
then
(true, false)
else
(false, false)
end
if not unchoppable then
return (consume this, consume b)
end
if a_left then
_alloc = _alloc + b._alloc
_size = _size + b._size
consume this
else
b._alloc = b._alloc + _alloc
b._size = b._size + _size
consume b
end
fun is_null_terminated(): Bool =>
"""
Return true if the string is null-terminated and safe to pass to an FFI
function that doesn't accept a size argument, expecting a null-terminator.
This method checks that there is a null byte just after the final position
of populated bytes in the string, but does not check for other null bytes
which may be present earlier in the content of the string.
If you need a null-terminated copy of this string, use the clone method.
"""
(_alloc > 0) and (_alloc != _size) and (_ptr._apply(_size) == 0)
fun utf32(offset: ISize): (U32, U8) ? =>
"""
Return a UTF32 representation of the character at the given offset and the
number of bytes needed to encode that character. If the offset does not
point to the beginning of a valid UTF8 encoding, return 0xFFFD (the unicode
replacement character) and a length of one. Raise an error if the offset is
out of bounds.
"""
let i = offset_to_index(offset)
let err: (U32, U8) = (0xFFFD, 1)
if i >= _size then error end
let c = _ptr._apply(i)
if c < 0x80 then
// 1-byte
(c.u32(), 1)
elseif c < 0xC2 then
// Stray continuation.
err
elseif c < 0xE0 then
// 2-byte
if (i + 1) >= _size then
// Not enough bytes.
err
else
let c2 = _ptr._apply(i + 1)
if (c2 and 0xC0) != 0x80 then
// Not a continuation byte.
err
else
(((c.u32() << 6) + c2.u32()) - 0x3080, 2)
end
end
elseif c < 0xF0 then
// 3-byte.
if (i + 2) >= _size then
// Not enough bytes.
err
else
let c2 = _ptr._apply(i + 1)
let c3 = _ptr._apply(i + 2)
if
// Not continuation bytes.
((c2 and 0xC0) != 0x80) or
((c3 and 0xC0) != 0x80) or
// Overlong encoding.
((c == 0xE0) and (c2 < 0xA0))
then
err
else
(((c.u32() << 12) + (c2.u32() << 6) + c3.u32()) - 0xE2080, 3)
end
end
elseif c < 0xF5 then
// 4-byte.
if (i + 3) >= _size then
// Not enough bytes.
err
else
let c2 = _ptr._apply(i + 1)
let c3 = _ptr._apply(i + 2)
let c4 = _ptr._apply(i + 3)
if
// Not continuation bytes.
((c2 and 0xC0) != 0x80) or
((c3 and 0xC0) != 0x80) or
((c4 and 0xC0) != 0x80) or
// Overlong encoding.
((c == 0xF0) and (c2 < 0x90)) or
// UTF32 would be > 0x10FFFF.
((c == 0xF4) and (c2 >= 0x90))
then
err
else
(((c.u32() << 18) +
(c2.u32() << 12) +
(c3.u32() << 6) +
c4.u32()) - 0x3C82080, 4)
end
end
else
// UTF32 would be > 0x10FFFF.
err
end
fun apply(i: USize): U8 ? =>
"""
Returns the i-th byte. Raise an error if the index is out of bounds.
"""
if i < _size then _ptr._apply(i) else error end
fun ref update(i: USize, value: U8): U8 ? =>
"""
Change the i-th byte. Raise an error if the index is out of bounds.
"""
if i < _size then
_set(i, value)
else
error
end
fun at_offset(offset: ISize): U8 ? =>
"""
Returns the byte at the given offset. Raise an error if the offset is out
of bounds.
"""
this(offset_to_index(offset))?
fun ref update_offset(offset: ISize, value: U8): U8 ? =>
"""
Changes a byte in the string, returning the previous byte at that offset.
Raise an error if the offset is out of bounds.
"""
this(offset_to_index(offset))? = value
fun clone(): String iso^ =>
"""
Returns a copy of the string. The resulting string is
null-terminated even if the original is not.
"""
let len = _size
let str = recover String(len) end
_ptr._copy_to(str._ptr._unsafe(), len)
str._size = len
str._set(len, 0)
str
fun repeat_str(num: USize = 1, sep: String = ""): String iso^ =>
"""
Returns a copy of the string repeated `num` times with an optional
separator added inbetween repeats.
"""
var c = num
var str = recover String((_size + sep.size()) * c) end
while c > 0 do
c = c - 1
str = (consume str)._append(this)
if (sep.size() > 0) and (c != 0) then
str = (consume str)._append(sep)
end
end
consume str
fun mul(num: USize): String iso^ =>
"""
Returns a copy of the string repeated `num` times.
"""
repeat_str(num)
fun find(s: String box, offset: ISize = 0, nth: USize = 0): ISize ? =>
"""
Return the index of the n-th instance of s in the string starting from the
beginning. Raise an error if there is no n-th occurrence of s or s is empty.
"""
var i = offset_to_index(offset)
var steps = nth + 1
while i < _size do
var j: USize = 0
let same = while j < s._size do
if _ptr._apply(i + j) != s._ptr._apply(j) then
break false
end
j = j + 1
true
else
false
end
if same and ((steps = steps - 1) == 1) then
return i.isize()
end
i = i + 1
end
error
fun rfind(s: String box, offset: ISize = -1, nth: USize = 0): ISize ? =>
"""
Return the index of n-th instance of `s` in the string starting from the
end. The `offset` represents the highest index to included in the search.
Raise an error if there is no n-th occurrence of `s` or `s` is empty.
"""
var i = (offset_to_index(offset) + 1) - s._size
var steps = nth + 1
while i < _size do
var j: USize = 0
let same = while j < s._size do
if _ptr._apply(i + j) != s._ptr._apply(j) then
break false
end
j = j + 1
true
else
false
end
if same and ((steps = steps - 1) == 1) then
return i.isize()
end
i = i - 1
end
error
fun contains(s: String box, offset: ISize = 0, nth: USize = 0): Bool =>
"""
Returns true if contains s as a substring, false otherwise.
"""
var i = offset_to_index(offset)
var steps = nth + 1
while i < _size do
var j: USize = 0
let same = while j < s._size do
if _ptr._apply(i + j) != s._ptr._apply(j) then
break false
end
j = j + 1
true
else
false
end
if same and ((steps = steps - 1) == 1) then
return true
end
i = i + 1
end
false
fun count(s: String box, offset: ISize = 0): USize =>
"""
Counts the non-overlapping occurrences of s in the string.
"""
let j: ISize = (_size - s.size()).isize()
var i: USize = 0
var k = offset
if j < 0 then
return 0
elseif (j == 0) and (this == s) then
return 1
end
try
while k <= j do
k = find(s, k)? + s.size().isize()
i = i + 1
end
end
i
fun at(s: String box, offset: ISize = 0): Bool =>
"""
Returns true if the substring s is present at the given offset.
"""
let i = offset_to_index(offset)
if (i + s.size()) <= _size then
@memcmp(_ptr._offset(i), s._ptr, s._size) == 0
else
false
end
fun ref delete(offset: ISize, len: USize = 1) =>
"""
Delete len bytes at the supplied offset, compacting the string in place.
"""
let i = offset_to_index(offset)
if i < _size then
let n = len.min(_size - i)
_size = _size - n
_ptr._offset(i)._delete(n, _size - i)
_set(_size, 0)
end
fun substring(from: ISize, to: ISize = ISize.max_value()): String iso^ =>
"""
Returns a substring. Index range [`from` .. `to`) is half-open.
Returns an empty string if nothing is in the range.
Note that this operation allocates a new string to be returned. For
similar operations that don't allocate a new string, see `trim` and
`trim_in_place`.
"""
let start = offset_to_index(from)
let finish = offset_to_index(to).min(_size)
if (start < _size) and (start < finish) then
let len = finish - start
let str = recover String(len) end
_ptr._offset(start)._copy_to(str._ptr._unsafe(), len)
str._size = len
str._set(len, 0)
str
else
recover String end
end
fun lower(): String iso^ =>
"""
Returns a lower case version of the string.
"""
let s = clone()
s.lower_in_place()
s
fun ref lower_in_place() =>
"""
Transforms the string to lower case. Currently only knows ASCII case.
"""
var i: USize = 0
while i < _size do
let c = _ptr._apply(i)
if (c >= 0x41) and (c <= 0x5A) then
_set(i, c + 0x20)
end
i = i + 1
end
fun upper(): String iso^ =>
"""
Returns an upper case version of the string. Currently only knows ASCII
case.
"""
let s = clone()
s.upper_in_place()
s
fun ref upper_in_place() =>
"""
Transforms the string to upper case.
"""
var i: USize = 0
while i < _size do
let c = _ptr._apply(i)
if (c >= 0x61) and (c <= 0x7A) then
_set(i, c - 0x20)
end
i = i + 1
end
fun reverse(): String iso^ =>
"""
Returns a reversed version of the string.
"""
let s = clone()
s.reverse_in_place()
s
fun ref reverse_in_place() =>
"""
Reverses the byte order in the string. This needs to be changed to handle
UTF-8 correctly.
"""
if _size > 1 then
var i: USize = 0
var j = _size - 1
while i < j do
let x = _ptr._apply(i)
_set(i, _ptr._apply(j))
_set(j, x)
i = i + 1
j = j - 1
end
end
fun ref push(value: U8) =>
"""
Add a byte to the end of the string.
"""
reserve(_size + 1)
_set(_size, value)
_size = _size + 1
_set(_size, 0)
fun ref pop(): U8 ? =>
"""
Remove a byte from the end of the string.
"""
if _size > 0 then
_size = _size - 1
_ptr._offset(_size)._delete(1, 0)
else
error
end
fun ref unshift(value: U8) =>
"""
Adds a byte to the beginning of the string.
"""
if value != 0 then
reserve(_size + 1)
@memmove(_ptr.usize() + 1, _ptr.usize(), _size + 1)
_set(0, value)
_size = _size + 1
else
_set(0, 0)
_size = 0
end
fun ref shift(): U8 ? =>
"""
Removes a byte from the beginning of the string.
"""
if _size > 0 then
let value = _ptr._apply(0)
@memmove(_ptr.usize(), _ptr.usize() + 1, _size)
_size = _size - 1
value
else
error
end
fun ref append(seq: ReadSeq[U8], offset: USize = 0, len: USize = -1) =>
"""
Append the elements from a sequence, starting from the given offset.
"""
if offset >= seq.size() then
return
end
let copy_len = len.min(seq.size() - offset)
reserve(_size + copy_len)
match seq
| let s: (String box | Array[U8] box) =>
s._copy_to(_ptr, copy_len, offset, _size)
_size = _size + copy_len
_set(_size, 0)
else
let cap = copy_len + offset
var i = offset
try
while i < cap do
push(seq(i)?)
i = i + 1
end
end
end
fun ref concat(iter: Iterator[U8], offset: USize = 0, len: USize = -1) =>
"""
Add len iterated bytes to the end of the string, starting from the given
offset.
"""
try
var n = USize(0)
while n < offset do
if iter.has_next() then
iter.next()?
else
return
end
n = n + 1
end
n = 0
while n < len do
if iter.has_next() then
push(iter.next()?)
else
return
end
n = n + 1
end
end
fun ref clear() =>
"""
Truncate the string to zero length.
"""
_set(0, 0)
_size = 0
fun insert(offset: ISize, that: String): String iso^ =>
"""
Returns a version of the string with the given string inserted at the given
offset.
"""
let s = clone()
s.insert_in_place(offset, that)
s
fun ref insert_in_place(offset: ISize, that: String box) =>
"""
Inserts the given string at the given offset. Appends the string if the
offset is out of bounds.
"""
reserve(_size + that._size)
let index = offset_to_index(offset).min(_size)
@memmove(_ptr.usize() + index + that._size,
_ptr.usize() + index, _size - index)
that._ptr._copy_to(_ptr._offset(index), that._size)
_size = _size + that._size
_set(_size, 0)
fun ref insert_byte(offset: ISize, value: U8) =>
"""
Inserts a byte at the given offset. Appends if the offset is out of bounds.
"""
reserve(_size + 1)
let index = offset_to_index(offset).min(_size)
@memmove(_ptr.usize() + index + 1, _ptr.usize() + index,
_size - index)
_set(index, value)
_size = _size + 1
_set(_size, 0)
fun cut(from: ISize, to: ISize = ISize.max_value()): String iso^ =>
"""
Returns a version of the string with the given range deleted.
Index range [`from` .. `to`) is half-open.
"""
let s = clone()
s.cut_in_place(from, to)
s
fun ref cut_in_place(from: ISize, to: ISize = ISize.max_value()) =>
"""
Cuts the given range out of the string.
Index range [`from` .. `to`) is half-open.
"""
let start = offset_to_index(from)
let finish = offset_to_index(to).min(_size)
if (start < _size) and (start < finish) and (finish <= _size) then
let fragment_len = finish - start
let new_size = _size - fragment_len
var i = start
while i < new_size do
_set(i, _ptr._apply(i + fragment_len))
i = i + 1
end
_size = _size - fragment_len
_set(_size, 0)
end
fun ref remove(s: String box): USize =>
"""
Remove all instances of s from the string. Returns the count of removed
instances.
"""
var i: ISize = 0
var n: USize = 0
try
while true do
i = find(s, i)?
cut_in_place(i, i + s.size().isize())
n = n + 1
end
end
n
fun ref replace(from: String box, to: String box, n: USize = 0): USize =>
"""
Replace up to n occurrences of `from` in `this` with `to`. If n is 0, all
occurrences will be replaced. Returns the count of replaced occurrences.
"""
let from_len = from.size().isize()
let to_len = to.size().isize()
var offset = ISize(0)
var occur = USize(0)
try
while true do
offset = find(from, offset)?
cut_in_place(offset, offset + from_len)
insert_in_place(offset, to)
offset = offset + to_len
occur = occur + 1
if (n > 0) and (occur >= n) then
break
end
end
end
occur
fun split_by(
delim: String,
n: USize = USize.max_value())
: Array[String] iso^
=>
"""
Split the string into an array of strings that are delimited by `delim` in
the original string. If `n > 0`, then the split count is limited to n.
Example:
```pony
let original: String = "<b><span>Hello!</span></b>"
let delimiter: String = "><"
let split_array: Array[String] = original.split_by(delimiter)
env.out.print("OUTPUT:")
for value in split_array.values() do
env.out.print(value)
end
// OUTPUT:
// <b
// span>Hello!</span
// b>
```
Adjacent delimiters result in a zero length entry in the array. For
example, `"1CutCut2".split_by("Cut") => ["1", "", "2"]`.
An empty delimiter results in an array that contains a single element equal
to the whole string.
If you want to split the string with each individual character of `delim`,
use [`split`](#split).
"""
let delim_size = ISize.from[USize](delim.size())
let total_size = ISize.from[USize](size())
let result = recover Array[String] end
var current = ISize(0)
while ((result.size() + 1) < n) and (current < total_size) do
try
let delim_start = find(delim where offset = current)?
result.push(substring(current, delim_start))
current = delim_start + delim_size
else break end
end
result.push(substring(current))
consume result
fun split(delim: String = " \t\v\f\r\n", n: USize = 0): Array[String] iso^ =>
"""
Split the string into an array of strings with any character in the
delimiter string. By default, the string is split with whitespace
characters. If `n > 0`, then the split count is limited to n.
Example:
```pony
let original: String = "name,job;department"
let delimiter: String = ".,;"
let split_array: Array[String] = original.split(delimiter)
env.out.print("OUTPUT:")
for value in split_array.values() do
env.out.print(value)
end
// OUTPUT:
// name
// job
// department
```
Adjacent delimiters result in a zero length entry in the array. For
example, `"1,,2".split(",") => ["1", "", "2"]`.
If you want to split the string with the entire delimiter string `delim`,
use [`split_by`](#split_by).
"""
let result = recover Array[String] end
if _size > 0 then
let chars = Array[U32](delim.size())
for rune in delim.runes() do
chars.push(rune)
end
var cur = recover String end
var i = USize(0)
var occur = USize(0)
try
while i < _size do
(let c, let len) = utf32(i.isize())?
if chars.contains(c) then
// If we find a delimiter, add the current string to the array.
occur = occur + 1
if (n > 0) and (occur >= n) then
break
end
result.push(cur = recover String end)
else
// Add bytes to the current string.
var j = U8(0)
while j < len do
cur.push(_ptr._apply(i + j.usize()))
j = j + 1
end
end
i = i + len.usize()
end
end
// Add all remaining bytes to the current string.
while i < _size do
cur.push(_ptr._apply(i))
i = i + 1
end
result.push(consume cur)
end
consume result
fun ref strip(s: String box = " \t\v\f\r\n") =>
"""
Remove all leading and trailing characters from the string that are in s.
"""
this .> lstrip(s) .> rstrip(s)
fun ref rstrip(s: String box = " \t\v\f\r\n") =>
"""
Remove all trailing characters within the string that are in s. By default,
trailing whitespace is removed.
"""
if _size > 0 then
let chars = Array[U32](s.size())
var i = _size - 1
var truncate_at = _size
for rune in s.runes() do
chars.push(rune)
end
repeat
try
match utf32(i.isize())?
| (0xFFFD, 1) => None
| (let c: U32, _) =>
if not chars.contains(c) then
break
end
truncate_at = i
end
else
break
end
until (i = i - 1) == 0 end
truncate(truncate_at)
end
fun ref lstrip(s: String box = " \t\v\f\r\n") =>
"""
Remove all leading characters within the string that are in s. By default,
leading whitespace is removed.
"""
if _size > 0 then
let chars = Array[U32](s.size())
var i = USize(0)
for rune in s.runes() do
chars.push(rune)
end
while i < _size do
try
(let c, let len) = utf32(i.isize())?
if not chars.contains(c) then
break
end
i = i + len.usize()
else
break
end
end
if i > 0 then
delete(0, i)
end
end
fun iso _append(s: String box): String iso^ =>
let len = _size + s._size
reserve(len)
if s.is_null_terminated() then
s._copy_to(_ptr._unsafe(), s._size + 1, 0, _size)
else
s._copy_to(_ptr._unsafe(), s._size, 0, _size)
end
_size = len
consume this
fun add(that: String box): String iso^ =>
"""
Return a string that is a concatenation of this and that.
"""
let len = _size + that._size
let s = recover String(len) end
(consume s)._append(this)._append(that)
fun join(data: Iterator[Stringable]): String iso^ =>
"""
Return a string that is a concatenation of the strings in data, using this
as a separator.
"""
var buf = recover String end
var first = true
for v in data do
if first then
first = false
else
buf = (consume buf)._append(this)
end
buf.append(v.string())
end
buf
fun compare(that: String box): Compare =>
"""
Lexically compare two strings.
"""
compare_sub(that, _size.max(that._size))
fun compare_sub(
that: String box,
n: USize,
offset: ISize = 0,
that_offset: ISize = 0,
ignore_case: Bool = false)
: Compare
=>
"""
Lexically compare at most `n` bytes of the substring of `this` starting at
`offset` with the substring of `that` starting at `that_offset`. The
comparison is case sensitive unless `ignore_case` is `true`.
If the substring of `this` is a proper prefix of the substring of `that`,
then `this` is `Less` than `that`. Likewise, if `that` is a proper prefix of
`this`, then `this` is `Greater` than `that`.
Both `offset` and `that_offset` can be negative, in which case the offsets
are computed from the end of the string.
If `n + offset` is greater than the length of `this`, or `n + that_offset`
is greater than the length of `that`, then the number of positions compared
will be reduced to the length of the longest substring.
Needs to be made UTF-8 safe.
"""
var j: USize = offset_to_index(offset)
var k: USize = that.offset_to_index(that_offset)
var i = n.min((_size - j).max(that._size - k))
while i > 0 do
// this and that are equal up to this point
if j >= _size then
// this is shorter
return Less
elseif k >= that._size then
// that is shorter
return Greater
end
let c1 = _ptr._apply(j)
let c2 = that._ptr._apply(k)
if
not ((c1 == c2) or
(ignore_case and ((c1 or 0x20) == (c2 or 0x20)) and
((c1 or 0x20) >= 'a') and ((c1 or 0x20) <= 'z')))
then
// this and that differ here
return if c1.i32() > c2.i32() then Greater else Less end
end
j = j + 1
k = k + 1
i = i - 1
end
Equal
fun eq(that: String box): Bool =>
"""
Returns true if the two strings have the same contents.
"""
if _size == that._size then
@memcmp(_ptr, that._ptr, _size) == 0
else
false
end
fun lt(that: String box): Bool =>
"""
Returns true if this is lexically less than that. Needs to be made UTF-8
safe.
"""
let len = _size.min(that._size)
var i: USize = 0
while i < len do
if _ptr._apply(i) < that._ptr._apply(i) then
return true
elseif _ptr._apply(i) > that._ptr._apply(i) then
return false
end
i = i + 1
end
_size < that._size
fun le(that: String box): Bool =>
"""
Returns true if this is lexically less than or equal to that. Needs to be
made UTF-8 safe.
"""
let len = _size.min(that._size)
var i: USize = 0
while i < len do
if _ptr._apply(i) < that._ptr._apply(i) then
return true
elseif _ptr._apply(i) > that._ptr._apply(i) then
return false
end
i = i + 1
end
_size <= that._size
fun offset_to_index(i: ISize): USize =>
if i < 0 then i.usize() + _size else i.usize() end
fun bool(): Bool ? =>
match lower()
| "true" => true
| "false" => false
else
error
end
fun i8(base: U8 = 0): I8 ? => _to_int[I8](base)?
fun i16(base: U8 = 0): I16 ? => _to_int[I16](base)?
fun i32(base: U8 = 0): I32 ? => _to_int[I32](base)?
fun i64(base: U8 = 0): I64 ? => _to_int[I64](base)?
fun i128(base: U8 = 0): I128 ? => _to_int[I128](base)?
fun ilong(base: U8 = 0): ILong ? => _to_int[ILong](base)?
fun isize(base: U8 = 0): ISize ? => _to_int[ISize](base)?
fun u8(base: U8 = 0): U8 ? => _to_int[U8](base)?
fun u16(base: U8 = 0): U16 ? => _to_int[U16](base)?
fun u32(base: U8 = 0): U32 ? => _to_int[U32](base)?
fun u64(base: U8 = 0): U64 ? => _to_int[U64](base)?
fun u128(base: U8 = 0): U128 ? => _to_int[U128](base)?
fun ulong(base: U8 = 0): ULong ? => _to_int[ULong](base)?
fun usize(base: U8 = 0): USize ? => _to_int[USize](base)?
fun _to_int[A: ((Signed | Unsigned) & Integer[A] val)](base: U8): A ? =>
"""
Convert the *whole* string to the specified type.
If there are any other characters in the string, or the integer found is
out of range for the target type then an error is thrown.
"""
(let v, let d) = read_int[A](0, base)?
// Check the whole string is used
if (d == 0) or (d.usize() != _size) then error end
v
fun read_int[A: ((Signed | Unsigned) & Integer[A] val)](
offset: ISize = 0,
base: U8 = 0)
: (A, USize /* chars used */) ?
=>
"""
Read an integer from the specified location in this string. The integer
value read and the number of bytes consumed are reported.
The base parameter specifies the base to use, 0 indicates using the prefix,
if any, to detect base 2, 10 or 16.
If no integer is found at the specified location, then (0, 0) is returned,
since no characters have been used.
An integer out of range for the target type throws an error.
A leading minus is allowed for signed integer types.
Underscore characters are allowed throughout the integer and are ignored.
"""
let start_index = offset_to_index(offset)
var index = start_index
var value: A = 0
var had_digit = false
// Check for leading minus
let minus = (index < _size) and (_ptr._apply(index) == '-')
if minus then
if A(-1) > A(0) then
// We're reading an unsigned type, negative not allowed, int not found
return (0, 0)
end
index = index + 1
end
(let base', let base_chars) = _read_int_base[A](base, index)
index = index + base_chars
// Process characters
while index < _size do
let char: A = A(0).from[U8](_ptr._apply(index))
if char == '_' then
index = index + 1
continue
end
let digit =
if (char >= '0') and (char <= '9') then
char - '0'
elseif (char >= 'A') and (char <= 'Z') then
(char - 'A') + 10
elseif (char >= 'a') and (char <= 'z') then
(char - 'a') + 10
else
break
end
if digit >= base' then
break
end
value = if minus then
(value *? base') -? digit
else
(value *? base') +? digit
end
had_digit = true
index = index + 1
end
// Check result
if not had_digit then
// No integer found
return (0, 0)
end
// Success
(value, index - start_index)
fun _read_int_base[A: ((Signed | Unsigned) & Integer[A] val)](
base: U8,
index: USize)
: (A, USize /* chars used */)
=>
"""
Determine the base of an integer starting at the specified index.
If a non-0 base is given use that. If given base is 0 read the base
specifying prefix, if any, to detect base 2 or 16.
If no base is specified and no prefix is found default to decimal.
Note that a leading 0 does NOT imply octal.
Report the base found and the number of single-byte characters in
the prefix.
"""
if base > 0 then
return (A(0).from[U8](base), 0)
end
// Determine base from prefix
if (index + 2) >= _size then
// Not enough characters, must be decimal
return (10, 0)
end
let lead_char = _ptr._apply(index)
let base_char = _ptr._apply(index + 1) and not 0x20
if (lead_char == '0') and (base_char == 'B') then
return (2, 2)
end
if (lead_char == '0') and (base_char == 'X') then
return (16, 2)
end
// No base specified, default to decimal
(10, 0)
fun f32(offset: ISize = 0): F32 ? =>
"""
Convert this string starting at the given offset
to a 32-bit floating point number ([F32](builtin-F32.md)).
This method errors if this string cannot be parsed to a float,
if the result would over- or underflow,
the offset exceeds the size of this string or
there are leftover characters in the string after conversion.
Examples:
```pony
"1.5".f32()? == F32(1.5)
"1.19208e-07".f32()? == F32(1.19208e-07)
"NaN".f32()?.nan() == true
```
"""
let index = offset_to_index(offset)
if index < _size then
let ptr = this.cstring()
var endp: Pointer[U8] box = Pointer[U8]
@pony_os_clear_errno()
let res = @strtof(ptr.offset(index), addressof endp)
let errno: I32 = @pony_os_errno()
if (errno != 0) or (endp != ptr.offset(_size)) then
error
else
res
end
else
error
end
fun f64(offset: ISize = 0): F64 ? =>
"""
Convert this string starting at the given offset
to a 64-bit floating point number ([F64](builtin-F64.md)).
This method errors if this string cannot be parsed to a float,
if the result would over- or underflow,
the offset exceeds the size of this string or
there are leftover characters in the string after conversion.
Examples:
```pony
"1.5".f64()? == F64(1.5)
"1.19208e-07".f64()? == F64(1.19208e-07)
"Inf".f64()?.infinite() == true
```
"""
let index = offset_to_index(offset)
if index < _size then
let ptr = this.cstring()
var endp: Pointer[U8] box = Pointer[U8]
@pony_os_clear_errno()
let res = @strtod(ptr.offset(index), addressof endp)
let errno: I32 = @pony_os_errno()
if (errno != 0) or (endp != ptr.offset(_size)) then
error
else
res
end
else
error
end
fun hash(): USize =>
@ponyint_hash_block(_ptr, _size)
fun hash64(): U64 =>
@ponyint_hash_block64(_ptr, _size)
fun string(): String iso^ =>
clone()
fun values(): StringBytes^ =>
"""
Return an iterator over the bytes in the string.
"""
StringBytes(this)
fun runes(): StringRunes^ =>
"""
Return an iterator over the codepoints in the string.
"""
StringRunes(this)
fun ref _set(i: USize, value: U8): U8 =>
"""
Unsafe update, used internally.
"""
_ptr._update(i, value)
class StringBytes is Iterator[U8]
let _string: String box
var _i: USize
new create(string: String box) =>
_string = string
_i = 0
fun has_next(): Bool =>
_i < _string.size()
fun ref next(): U8 ? =>
_string(_i = _i + 1)?
class StringRunes is Iterator[U32]
let _string: String box
var _i: USize
new create(string: String box) =>
_string = string
_i = 0
fun has_next(): Bool =>
_i < _string.size()
fun ref next(): U32 ? =>
(let rune, let len) = _string.utf32(_i.isize())?
_i = _i + len.usize()
rune
primitive _UTF32Encoder
fun encode(value: U32): (USize, U8, U8, U8, U8) =>
"""
Encode the code point into UTF-8. It returns a tuple with the size of the
encoded data and then the data.
"""
if value < 0x80 then
(1, value.u8(), 0, 0, 0)
elseif value < 0x800 then
( 2,
((value >> 6) or 0xC0).u8(),
((value and 0x3F) or 0x80).u8(),
0,
0
)
elseif value < 0xD800 then
( 3,
((value >> 12) or 0xE0).u8(),
(((value >> 6) and 0x3F) or 0x80).u8(),
((value and 0x3F) or 0x80).u8(),
0
)
elseif value < 0xE000 then
// UTF-16 surrogate pairs are not allowed.
(3, 0xEF, 0xBF, 0xBD, 0)
elseif value < 0x10000 then
( 3,
((value >> 12) or 0xE0).u8(),
(((value >> 6) and 0x3F) or 0x80).u8(),
((value and 0x3F) or 0x80).u8(),
0
)
elseif value < 0x110000 then
( 4,
((value >> 18) or 0xF0).u8(),
(((value >> 12) and 0x3F) or 0x80).u8(),
(((value >> 6) and 0x3F) or 0x80).u8(),
((value and 0x3F) or 0x80).u8()
)
else
// Code points beyond 0x10FFFF are not allowed.
(3, 0xEF, 0xBF, 0xBD, 0)
end
| pony | 6182652 | https://sv.wikipedia.org/wiki/San%20Felipe%2C%20Chile | San Felipe, Chile | {{geobox
| 1 = Settlement
| name = San Felipe
| native_name =
| other_name =
| category = Stad
| etymology =
| official_name =
| motto =
| nickname =
| image = SANFELIPEVISTAAEREA2018.jpg
| image_caption = Vy över San Felipe, 2018.
| flag = Bandera de San Felipe.svg
| symbol = Escudo de San Felipe.svg
| symbol_type =
| country = Chile
| country_flag = true
| state =
| state_type =
| region = Valparaíso
| region_type =
| district = San Felipe de Aconcagua
| district_type = Provins
| municipality = San Felipe
| municipality_type =
| part =
| landmark =
| river =
| location =
| elevation = 654
| lat_d = -32.74976
| lat_m =
| lat_s =
| lat_NS =
| long_d = -70.72584
| long_m =
| long_s =
| long_EW =
| highest =
| highest_note =
| highest_elevation =
| highest_elevation_note =
| lowest =
| lowest_note =
| lowest_elevation =
| lowest_elevation_note =
| length =
| length_orientation =
| width =
| width_orientation =
| area = 15.46 | area_note = | area_decimals =
| area_land =
| area_water =
| area_urban = 10.71 | area_urban_note = <ref name="ChileAUC"> [http://www.ide.cl/descargas/capas/minvu/Area_Urbana_Consolidada.zip Ministerio de Vivienda y Urbanismo, Chile; Área Urbana Consolidada (komprimerad fil'')] Dataset med kartor och statistik. Läst 1 januari 2020.</ref> | area_urban_decimals = | area_urban_type = tätort
| area_metro = 15.59 | area_metro_note = | area_metro_decimals =
| population = 64120 | population_date = 19 april 2017 | population_note =
| population_urban = 61407 | population_urban_date = 19 april 2017 | population_urban_note = | population_urban_type = tätort
| population_metro = 64543 | population_metro_date = 19 april 2017 | population_metro_note =
| population_density = auto
| population_urban_density = auto | population_urban_density_type = tätort
| population_metro_density = auto | population_metro_density_note =
| population1 =
| population1_type =
| established =
| established_type =
| date =
| date_type =
| government =
| government_location =
| government_region =
| government_state =
| mayor =
| mayor_party =
| leader =
| leader_type =
| timezone = BRT
| utc_offset = -3
| timezone_DST = EDT
| utc_offset_DST = -4
| postal_code =
| postal_code_type =
| area_code =
| area_code_type =
| code =
| code_type =
| code1 =
| code1_type =
| free =
| free_type =
| free1 =
| free1_type =
| map =
| map_caption =
| map_locator = Chile
| map_locator_x =
| map_locator_y =
| website =
| footnotes =
| timezone_label = America/Santiago
}}San Felipe''' är en stad i centrala Chile, och tillhör regionen Valparaíso. Den är huvudort för provinsen San Felipe de Aconcagua och hade cirka 64 000 invånare vid folkräkningen 2017.
Källor
Externa länkar
Orter i Región de Valparaíso | swedish | 1.041284 |
Pony/signals--index-.txt |
Signals package¶
The Signals package provides support for handling Unix style signals.
For each signal that you want to handle, you need to create a SignalHandler
and a corresponding SignalNotify object. Each SignalHandler runs as it own
actor and upon receiving the signal will call its corresponding
SignalNotify's apply method.
Example program¶
The following program will listen for the TERM signal and output a message to
standard out if it is received.
use "signals"
actor Main
new create(env: Env) =>
// Create a TERM handler
let signal = SignalHandler(TermHandler(env), Sig.term())
// Raise TERM signal
signal.raise()
class TermHandler is SignalNotify
let _env: Env
new iso create(env: Env) =>
_env = env
fun ref apply(count: U32): Bool =>
_env.out.print("TERM signal received")
true
Signal portability¶
The Sig primitive provides support for portable signal handling across Linux,
FreeBSD and OSX. Signals are not supported on Windows and attempting to use
them will cause a compilation error.
Shutting down handlers¶
Unlike a TCPConnection and other forms of input receiving, creating a
SignalHandler will not keep your program running. As such, you are not
required to call dispose on your signal handlers in order to shutdown your
program.
Public Types¶
primitive Sig
actor SignalHandler
interface SignalNotify
primitive SignalRaise
| pony | 1489250 | https://no.wikipedia.org/wiki/Unix-signal | Unix-signal | Et Unix-signal er en begrenset form for interprosesskommunikasjon som er brukt i UNIX, Unix-lignende og andre POSIX-kompatible operativsystemer. Et signal er en asynkron notifikasjon som sendes til en prosess eller til en spesifikk tråd innenfor den samme prosess for å melde fra som en hendelse som har foregått. Signaler oppstod på 1970-tallet ved Bell Laboratories og ble senere spesifisert i standarden POSIX.
SIGINT (fra engelsk Signal Interrupt, avbruddssignal) er et signal som sendes til en prosess fra kjernen i operativsystemet. En slikt signal sendes for eksempel når en bruker ønsker å stoppe et program og trykker Control-C for å avslutte det.
SIGSEGV (fra engelsk Signal Segmentation Violation, minnesegmentsfeil-signal) er et signal som indikerer at en prosess har utført en minnesegmentsfeil.
SIGTERM (fra engelsk Signal Terminate, termineringssignal) er et signal som sendes til en prosess fra kjernen i operativsystemet, når det er et ønske om at denne prosessen skal avslutte. SIGTERM-signalet gir prosessen beskjed om å rydde opp etter seg og deretter avslutte. Velskrevne programmer er i stand til å fange opp, det vil si registrere at det har mottatt, et SIGTERM-signal og foreta den nødvendige opprydningen. Når et UNIX-operativsystem avsluttes er det normalt at et SIGTERM signal sendes til hver kjørende prosess. Deretter får programmene noen sekunder på å rydde opp, før eventuelle gjenværende programmer avsluttes med SIGKILL. Signalet sendes normalt ved hjelp av systemkallet eller kommandoen kill.
SIGKILL (fra engelsk Signal Kill, drapssignal) er et signal som brukes når en ønsker at en prosess skal bli drept. En prosess kan aldri fange opp, det vil si registrere at det har mottatt, et SIGKILL-signal, så en prosess kan aldri velge å overse et SIGKILL-signal. Dette gjør at det å sende et SIGKILL-signal til en prosess er en sikker måte å drepe prosessen på.
Signalet sendes normalt ved hjelp av systemkallet eller kommandoen kill.
Eksterne lenker
Unix Signals Table, Ali Alanjawi, University of Pittsburgh
Man7.org Signal Man Page
POSIX | norwegian_bokmål | 0.470024 |
Pony/src-collections-flag-.txt |
flag.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194interface val Flag[A: (Unsigned & Integer[A] val)]
"""
A flag should be a primitive with a value method that returns the bits that
represent the flag. This allows a flag to encode a single bit, or any
combination of bits.
"""
fun value(): A
class Flags[A: Flag[B] val, B: (Unsigned & Integer[B] val) = U64] is
Comparable[Flags[A, B] box]
"""
Flags is a set of flags. The flags that are recognised should be passed as
a union type for type parameter A. For example:
primitive SSE
fun value(): U64 => 1
primitive AVX
fun value(): U64 => 2
primitive RDTSCP
fun value(): U64 => 4
type Features is Flags[(SSE | AVX | RDTSCP)]
Type parameter B is the underlying field used to store the flags.
"""
var _value: B = 0
new iso create(value': B = 0) =>
"""
Create a Flags instance with an optional initial value.
Default is 0 (no flags set).
"""
_value = value'
fun value(): B =>
"""
Returns the bit encoding of the set flags.
"""
_value
fun apply(flag: A): Bool =>
"""
Returns true if the flag is set.
"""
(_value and flag.value()) > 0
fun ref all() =>
"""
Sets all bits, including undefined flags.
"""
_value = -1
fun ref clear() =>
"""
Unsets all flags.
"""
_value = 0
fun ref set(flag: A) =>
"""
Sets the flag.
"""
_value = _value or flag.value()
fun ref unset(flag: A) =>
"""
Unsets the flag.
"""
_value = _value and not flag.value()
fun ref flip(flag: A) =>
"""
Sets the flag if it is unset, unsets the flag if it is set.
"""
_value = _value xor flag.value()
fun ref union(that: Flags[A, B] box) =>
"""
The union of this and that.
"""
_value = this._value or that._value
fun ref intersect(that: Flags[A, B] box) =>
"""
The intersection of this and that.
"""
_value = this._value and that._value
fun ref difference(that: Flags[A, B] box) =>
"""
The symmetric difference of this and that.
"""
_value = this._value xor that._value
fun ref remove(that: Flags[A, B] box) =>
"""
Unset flags that are set in that.
"""
_value = this._value and not that._value
fun add(flag: A): Flags[A, B] iso^ =>
"""
This with the flag set.
"""
let f = recover Flags[A, B] end
f._value = this._value or flag.value()
f
fun sub(flag: A): Flags[A, B] iso^ =>
"""
This with the flag unset.
"""
let f = recover Flags[A, B] end
f._value = this._value and not flag.value()
f
fun op_or(that: Flags[A, B] box): Flags[A, B] iso^ =>
"""
The union of this and that.
"""
let f = recover Flags[A, B] end
f._value = this._value or that._value
f
fun op_and(that: Flags[A, B] box): Flags[A, B] iso^ =>
"""
The intersection of this and that.
"""
let f = recover Flags[A, B] end
f._value = this._value and that._value
f
fun op_xor(that: Flags[A, B] box): Flags[A, B] iso^ =>
"""
The symmetric difference of this and that.
"""
let f = recover Flags[A, B] end
f._value = this._value xor that._value
f
fun without(that: Flags[A, B] box): Flags[A, B] iso^ =>
"""
The flags in this that are not in that.
"""
let f = recover Flags[A, B] end
f._value = this._value and not that._value
f
fun clone(): Flags[A, B] iso^ =>
"""
Create a clone.
"""
let f = recover Flags[A, B] end
f._value = this._value
f
fun eq(that: Flags[A, B] box): Bool =>
"""
Returns true if this has the same flags set as that.
"""
_value == that._value
fun lt(that: Flags[A, B] box): Bool =>
"""
Returns true if the flags set on this are a strict subset of the flags set
on that. Flags is only partially ordered, so lt is not the opposite of ge.
"""
(_value != that._value) and ((_value and not that._value) == 0)
fun le(that: Flags[A, B] box): Bool =>
"""
Returns true if the flags set on this are a subset of the flags set on
that or they are the same. Flags is only partially ordered, so le is not
the opposite of te.
"""
((_value and not that._value) == 0)
fun gt(that: Flags[A, B] box): Bool =>
"""
Returns true if the flags set on this are a struct superset of the flags
set on that. Flags is only partially ordered, so gt is not the opposite of
le.
"""
(_value != that._value) and ((that._value and not _value) == 0)
fun ge(that: Flags[A, B] box): Bool =>
"""
Returns true if the flags set on this are a superset of the flags set on
that or they are the same. Flags is only partially ordered, so ge is not
the opposite of lt.
"""
((that._value and not _value) == 0)
| pony | 4875271 | https://sv.wikipedia.org/wiki/Flagga%20%28data%29 | Flagga (data) | Inom programmering och processorarkitektur är en flagga en binär variabel som används för att ange två olika tillstånd. Ofta samlar man flaggor i ett heltal, där de olika bitarna är flaggor för olika tillstånd. Flaggor kan sättas (ges värdet 1), nollställas (ges värdet 0) och avläsas.
Exempel
Processorns statusregister
I, till exempel, 6502-processorns statusregister lagras följande information som ett åttabitars heltal:
Referenser
Programmering | swedish | 0.99038 |
Pony/format-FormatHex-.txt |
FormatHex¶
[Source]
primitive val FormatHex is
FormatSpec val
Implements¶
FormatSpec val
Constructors¶
create¶
[Source]
new val create()
: FormatHex val^
Returns¶
FormatHex val^
Public Functions¶
eq¶
[Source]
fun box eq(
that: FormatHex val)
: Bool val
Parameters¶
that: FormatHex val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FormatHex val)
: Bool val
Parameters¶
that: FormatHex val
Returns¶
Bool val
| pony | 703838 | https://sv.wikipedia.org/wiki/XForms | XForms | XForms är en W3C-standard för att beskriva ett webb-formulär med hjälp av XML.
XForms har tre huvuddelar vilka är:
XForms-modellen
datamodellen
användargränssnittet
XForms version 1.0 antogs som rekommendation 2007-10-29 av W3C.
Se även
XPATH
HTML
XHTML
W3C-standarder | swedish | 0.84561 |
Pony/serialise-Serialised-.txt |
Serialised¶
[Source]
This represents serialised data. How it can be used depends on the other
capabilities a caller holds.
class val Serialised
Constructors¶
create¶
[Source]
A caller with SerialiseAuth can create serialised data from any object.
new ref create(
auth: SerialiseAuth val,
data: Any box)
: Serialised ref^ ?
Parameters¶
auth: SerialiseAuth val
data: Any box
Returns¶
Serialised ref^ ?
input¶
[Source]
A caller with InputSerialisedAuth can create serialised data from any
arbitrary set of bytes. It is the caller's responsibility to ensure that
the data is in fact well-formed serialised data. This is currently the most
dangerous method, as there is currently no way to check validity at
runtime.
new ref input(
auth: InputSerialisedAuth val,
data: Array[U8 val] val)
: Serialised ref^
Parameters¶
auth: InputSerialisedAuth val
data: Array[U8 val] val
Returns¶
Serialised ref^
Public Functions¶
apply¶
[Source]
A caller with DeserialiseAuth can create an object graph from serialised
data.
fun box apply(
auth: DeserialiseAuth val)
: Any iso^ ?
Parameters¶
auth: DeserialiseAuth val
Returns¶
Any iso^ ?
output¶
[Source]
A caller with OutputSerialisedAuth can gain access to the underlying bytes
that contain the serialised data. This can be used to write those bytes to,
for example, a file or socket.
fun box output(
auth: OutputSerialisedAuth val)
: Array[U8 val] val
Parameters¶
auth: OutputSerialisedAuth val
Returns¶
Array[U8 val] val
| pony | 3071209 | https://sv.wikipedia.org/wiki/Spialia%20abscondita | Spialia abscondita | Spialia abscondita är en fjärilsart som beskrevs av Carl Plötz 1884. Spialia abscondita ingår i släktet Spialia och familjen tjockhuvuden. Inga underarter finns listade i Catalogue of Life.
Källor
Tjockhuvuden
abscondita | swedish | 1.259226 |
Pony/collections-persistent-Lists-.txt |
Lists[A: A]¶
[Source]
A primitive containing helper functions for constructing and
testing Lists.
primitive val Lists[A: A]
Constructors¶
create¶
[Source]
new val create()
: Lists[A] val^
Returns¶
Lists[A] val^
Public Functions¶
empty¶
[Source]
Returns an empty list.
fun box empty()
: (Cons[A] val | Nil[A] val)
Returns¶
(Cons[A] val | Nil[A] val)
cons¶
[Source]
Returns a list that has h as a head and t as a tail.
fun box cons(
h: val->A,
t: (Cons[A] val | Nil[A] val))
: (Cons[A] val | Nil[A] val)
Parameters¶
h: val->A
t: (Cons[A] val | Nil[A] val)
Returns¶
(Cons[A] val | Nil[A] val)
apply¶
[Source]
Builds a new list from an Array
fun box apply(
arr: Array[val->A] ref)
: (Cons[A] val | Nil[A] val)
Parameters¶
arr: Array[val->A] ref
Returns¶
(Cons[A] val | Nil[A] val)
from¶
[Source]
Builds a new list from an iterator
fun box from(
iter: Iterator[val->A] ref)
: (Cons[A] val | Nil[A] val)
Parameters¶
iter: Iterator[val->A] ref
Returns¶
(Cons[A] val | Nil[A] val)
eq[optional T: Equatable[T] val]¶
[Source]
Checks whether two lists are equal.
fun box eq[optional T: Equatable[T] val](
l1: (Cons[T] val | Nil[T] val),
l2: (Cons[T] val | Nil[T] val))
: Bool val ?
Parameters¶
l1: (Cons[T] val | Nil[T] val)
l2: (Cons[T] val | Nil[T] val)
Returns¶
Bool val ?
ne¶
[Source]
fun box ne(
that: Lists[A] val)
: Bool val
Parameters¶
that: Lists[A] val
Returns¶
Bool val
| pony | 2150052 | https://sv.wikipedia.org/wiki/Ascorhynchus%20longicollis | Ascorhynchus longicollis | Ascorhynchus longicollis är en havsspindelart som beskrevs av Haswell, W.A. 1884. Ascorhynchus longicollis ingår i släktet Ascorhynchus och familjen Ammotheidae. Inga underarter finns listade i Catalogue of Life.
Källor
Havsspindlar
longicollis | swedish | 1.277469 |
Pony/builtin-Bool-.txt |
Bool¶
[Source]
primitive val Bool is
Stringable box
Implements¶
Stringable box
Constructors¶
create¶
[Source]
new val create(
from: Bool val)
: Bool val^
Parameters¶
from: Bool val
Returns¶
Bool val^
Public Functions¶
eq¶
[Source]
fun box eq(
y: Bool val)
: Bool val
Parameters¶
y: Bool val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
y: Bool val)
: Bool val
Parameters¶
y: Bool val
Returns¶
Bool val
op_and¶
[Source]
fun box op_and(
y: Bool val)
: Bool val
Parameters¶
y: Bool val
Returns¶
Bool val
op_or¶
[Source]
fun box op_or(
y: Bool val)
: Bool val
Parameters¶
y: Bool val
Returns¶
Bool val
op_xor¶
[Source]
fun box op_xor(
y: Bool val)
: Bool val
Parameters¶
y: Bool val
Returns¶
Bool val
op_not¶
[Source]
fun box op_not()
: Bool val
Returns¶
Bool val
string¶
[Source]
fun box string()
: String iso^
Returns¶
String iso^
| pony | 161775 | https://nn.wikipedia.org/wiki/Tolv%20sonatar%20for%20to%20fiolinar%20og%20basso%20continuo%2C%20Opus%201 | Tolv sonatar for to fiolinar og basso continuo, Opus 1 | Opus 1 er ei samling sonatar som Antonio Vivaldi komponerte i 1705.
Sonate nr. 1 i G-moll, RV 73
Sonate nr. 2 i E-moll, RV 67
Sonate nr. 3 i C-dur, RV 61
Sonate nr. 4 i E-dur, RV 66
Sonate nr. 5 i F-dur, RV 69
Sonate nr. 6 i D-dur, RV 62
Sonate nr. 7 i Ess-dur, RV 65
Sonate nr. 8 i D-moll, RV 64
Sonate nr. 9 i A-dur, RV 75
Sonate nr. 10 i B-dur, RV 78
Sonate nr. 11 i B-moll, RV 79
Sonate nr. 12 i D-moll, RV 63
Den siste sonaten er ei samling variasjonar over det kjende 'La Folia'-temaet.
Musikkverk av Antonio Vivaldi | norwegian_nynorsk | 1.216969 |
Pony/1_variables.txt | # Variables
Like most other programming languages Pony allows you to store data in variables. There are a few different kinds of variables which have different lifetimes and are used for slightly different purposes.
## Local variables
Local variables in Pony work very much as they do in other languages, allowing you to store temporary values while you perform calculations. Local variables live within a chunk of code (they are _local_ to that chunk) and are created every time that code chunk executes and disposed of when it completes.
To define a local variable the `var` keyword is used (`let` can also be used, but we'll get to that later). Right after the `var` comes the variable's name, and then you can (optionally) put a `:` followed by the variable's type. For example:
```pony
var x: String = "Hello"
```
Here, we're assigning the __string literal__ `"Hello"` to `x`.
You don't have to give a value to the variable when you define it: you can assign one later if you prefer. If you try to read the value from a variable before you've assigned one, the compiler will complain instead of allowing the dreaded _uninitialised variable_ bug.
Every variable has a type, but you don't have to specify it in the declaration if you provide an initial value. The compiler will automatically use the type of the initial value of the variable.
The following definitions of `x`, `y` and `z` are all effectively identical.
```pony
var x: String = "Hello"
var y = "Hello"
var z: String
z = "Hello"
```
__Can I miss out both the type and initial value for a variable?__ No. The compiler will complain that it can't figure out a type for that variable.
All local variable names start with a lowercase letter. If you want to you can end them with a _prime_ `'` (or more than one) which is useful when you need a second variable with almost the same meaning as the first. For example, you might have one variable called `time` and another called `time'`.
The chunk of code that a variable lives in is known as its __scope__. Exactly what its scope is depends on where it is defined. For example, the scope of a variable defined within the `then` expression of an `if` statement is that `then` expression. We haven't looked at `if` statements yet, but they're very similar to every other language.
```pony
if a > b then
var x = "a is bigger"
env.out.print(x) // OK
end
env.out.print(x) // Illegal
```
Variables only exist from when they are defined until the end of the current scope. For our variable `x` this is the `end` at the end of the then expression: after that, it cannot be used.
## Var vs. let
Local variables are declared with either a `var` or a `let`. Using `var` means the variable can be assigned and reassigned as many times as you like. Using `let` means the variable can only be assigned once.
```pony
var x: U32 = 3
let y: U32 = 4
x = 5 // OK
y = 6 // Error, y is let
```
Using `let` instead of `var` also means the variable has to be assigned immediately.
```pony
let x: U32 = 3 // Ok
let y: U32 // Error, can't declare a let local without assigning to it
y = 6 // Error, can't reassign to a let local
```
Note that a variable having been declared with `let` only restricts reassignment, and does not influence the mutability of the object it references. This is the job of reference capabilities, explained later in this tutorial.
You never have to declare variables as `let`, but if you know you're never going to change what a variable references then using `let` is a good way to catch errors. It can also serve as a useful comment, indicating what is referenced is not meant to be changed.
## Fields
In Pony, fields are variables that live within objects. They work like fields in other object-oriented languages.
Fields have the same lifetime as the object they're in, rather than being scoped. They are set up by the object constructor and disposed of along with the object.
If the name of a field starts with `_`, it's __private__. That means only the type the field is in can have code that reads or writes that field. Otherwise, the field is __public__ and can be read or written from anywhere.
Just like local variables, fields can be `var` or `let`. Nevertheless, rules for field assignment differ a bit from variable assignment. No matter the type of the field (either `var` or `let`), either:
1. an initial value has to be assigned in their definition or
2. an initial value has to be assigned in the constructor method.
In the example below, the initial value of the two fields of the class `Wombat` is assigned at the definition level:
```pony
class Wombat
let name: String = "Fantastibat"
var _hunger_level: U32 = 0
```
Alternatively, these fields could be assigned in the constructor method:
```pony
class Wombat
let name: String
var _hunger_level: U32
new create(hunger: U32) =>
name = "Fantastibat"
_hunger_level = hunger
```
If the assignment is not done at the definition level or in the constructor, an error is raised by the compiler. This is true for both `var` and `let` fields.
Please note that the assignment of a value to a field has to be explicit. The below example raises an error when compiled, even when the field is of `var` type:
```pony
class Wombat
let name: String
var _hunger_level: U64
new ref create(name': String, level: U64) =>
name = name'
set_hunger_level(level)
// Error: field _hunger_level left undefined in constructor
fun ref set_hunger_level(hunger_level: U64) =>
_hunger_level = hunger_level
```
We will see later in the Methods section that a class can have several constructors. For now, just remember that if the assignment of a field is not done at the definition level, it has to be done in each constructor of the class the field belongs to.
As for variables, using `var` means a field can be assigned and reassigned as many times as you like in the class. Using `let` means the field can only be assigned once.
```pony
class Wombat
let name: String
var _hunger_level: U64
new ref create(name': String, level: U64) =>
name = name'
_hunger_level = level
fun ref set_hunger_level(hunger_level: U64) =>
_hunger_level = hunger_level // Ok, _hunger_level is of var type
fun ref set_name(name' : String) =>
name = name' // Error, can't assign to a let definition more than once
```
__Can field declarations appear after methods?__ No. If `var` or `let` keywords appear after a `fun` or `be` declaration, they will be treated as variables within the method body rather than fields within the type declaration. As a result, fields must appear prior to methods in the type declaration
## Embedded Fields
Unlike local variables, some types of fields can be declared using `embed`. Specifically, only classes or structs can be embedded - interfaces, traits, primitives and numeric types cannot. A field declared using `embed` is similar to one declared using `let`, but at the implementation level, the memory for the embedded class is laid out directly within the outer class. Contrast this with `let` or `var`, where the implementation uses pointers to reference the field class. Embedded fields can be passed to other functions in exactly the same way as `let` or `var` fields. Embedded fields must be initialised from a constructor expression.
__Why would I use `embed`?__ `embed` avoids a pointer indirection when accessing a field and a separate memory allocation when creating that field. By default, it is advised to use `embed` if possible. However, since an embedded field is allocated alongside its parent object, exterior references to the field forbids garbage collection of the parent, which can result in higher memory usage if a field outlives its parent. Use `let` if this is a concern for you.
## Global variables
Some programming languages have __global variables__ that can be accessed from anywhere in the code. What a bad idea! Pony doesn't have global variables at all.
## Shadowing
Some programming languages let you declare a variable with the same name as an existing variable, and then there are rules about which one you get. This is called _shadowing_, and it's a source of bugs. If you accidentally shadow a variable in Pony, the compiler will complain.
If you need a variable with _nearly_ the same name, you can use a prime `'`.
| pony | 2136884 | https://sv.wikipedia.org/wiki/Heptacarpus%20stylus | Heptacarpus stylus | Heptacarpus stylus är en kräftdjursart som först beskrevs av William Stimpson 1864. Heptacarpus stylus ingår i släktet Heptacarpus och familjen Hippolytidae. Inga underarter finns listade i Catalogue of Life.
Källor
Tiofotade kräftdjur
stylus | swedish | 1.316312 |
Pony/src-collections-persistent-list-.txt |
list.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582type List[A] is (Cons[A] | Nil[A])
"""
A persistent list with functional transformations.
## Usage
```pony
use "collections/persistent"
actor Main
new create(env: Env) =>
try
let l1 = Lists[U32]([2; 4; 6; 8]) // List(2, 4, 6, 8)
let empty = Lists[U32].empty() // List()
// prepend() returns a new List, leaving the
// old list unchanged
let l2 = empty.prepend(3) // List(3)
let l3 = l2.prepend(2) // List(2, 3)
let l4 = l3.prepend(1) // List(1, 2, 3)
let l4_head = l4.head() // 1
let l4_tail = l4.tail() // List(2, 3)
l4_head == 1
Lists[U32].eq(l4, Lists[U32]([1; 2; 3]))?
Lists[U32].eq(l4_tail, Lists[U32]([2; 3]))?
let doubled = l4.map[U32]({(x) => x * 2 })
Lists[U32].eq(doubled, Lists[U32]([2; 4; 6]))?
end
```
"""
primitive Lists[A]
"""
A primitive containing helper functions for constructing and
testing Lists.
"""
fun empty(): List[A] =>
"""
Returns an empty list.
"""
Nil[A]
fun cons(h: val->A, t: List[A]): List[A] =>
"""
Returns a list that has h as a head and t as a tail.
"""
Cons[A](h, t)
fun apply(arr: Array[val->A]): List[A] =>
"""
Builds a new list from an Array
"""
this.from(arr.values())
fun from(iter: Iterator[val->A]): List[A] =>
"""
Builds a new list from an iterator
"""
var l: List[A] = Nil[A]
for i in iter do
l = Cons[A](i, l)
end
l.reverse()
fun eq[T: Equatable[T] val = A](l1: List[T], l2: List[T]): Bool ? =>
"""
Checks whether two lists are equal.
"""
if (l1.is_empty() and l2.is_empty()) then
true
elseif (l1.is_empty() and l2.is_non_empty()) then
false
elseif (l1.is_non_empty() and l2.is_empty()) then
false
elseif (l1.head()? != l2.head()?) then
false
else
eq[T](l1.tail()?, l2.tail()?)?
end
primitive Nil[A] is ReadSeq[val->A]
"""
The empty list of As.
"""
fun size(): USize =>
"""
Returns the size of the list.
"""
0
fun apply(i: USize): val->A ? =>
"""
Returns the i-th element of the sequence. For the empty list this call will
always error because any index will be out of bounds.
"""
error
fun values(): Iterator[val->A]^ =>
"""
Returns an empty iterator over the elements of the empty list.
"""
object ref is Iterator[val->A]
fun has_next(): Bool => false
fun ref next(): val->A! ? => error
end
fun is_empty(): Bool =>
"""
Returns a Bool indicating if the list is empty.
"""
true
fun is_non_empty(): Bool =>
"""
Returns a Bool indicating if the list is non-empty.
"""
false
fun head(): val->A ? =>
"""
Returns an error, since Nil has no head.
"""
error
fun tail(): List[A] ? =>
"""
Returns an error, since Nil has no tail.
"""
error
fun reverse(): Nil[A] =>
"""
The reverse of the empty list is the empty list.
"""
this
fun prepend(a: val->A!): Cons[A] =>
"""
Builds a new list with an element added to the front of this list.
"""
Cons[A](consume a, this)
fun concat(l: List[A]): List[A] =>
"""
The concatenation of any list l with the empty list is l.
"""
l
fun map[B](f: {(val->A): val->B} box): Nil[B] =>
"""
Mapping a function from A to B over the empty list yields the
empty list of Bs.
"""
Nil[B]
fun flat_map[B](f: {(val->A): List[B]} box): Nil[B] =>
"""
Flatmapping a function from A to B over the empty list yields the
empty list of Bs.
"""
Nil[B]
fun for_each(f: {(val->A)} box) =>
"""
Applying a function to every member of the empty list is a no-op.
"""
None
fun filter(f: {(val->A): Bool} box): Nil[A] =>
"""
Filtering the empty list yields the empty list.
"""
this
fun fold[B](f: {(B, val->A): B^} box, acc: B): B =>
"""
Folding over the empty list yields the initial accumulator.
"""
consume acc
fun every(f: {(val->A): Bool} box): Bool =>
"""
Any predicate is true of every member of the empty list.
"""
true
fun exists(f: {(val->A): Bool} box): Bool =>
"""
For any predicate, there is no element that satisfies it in the empty
list.
"""
false
fun partition(f: {(val->A): Bool} box): (Nil[A], Nil[A]) =>
"""
The only partition of the empty list is two empty lists.
"""
(this, this)
fun drop(n: USize): Nil[A] =>
"""
There are no elements to drop from the empty list.
"""
this
fun drop_while(f: {(val->A): Bool} box): Nil[A] =>
"""
There are no elements to drop from the empty list.
"""
this
fun take(n: USize): Nil[A] =>
"""
There are no elements to take from the empty list.
"""
this
fun take_while(f: {(val->A): Bool} box): Nil[A] =>
"""
There are no elements to take from the empty list.
"""
this
fun val contains[T: (A & HasEq[A!] #read) = A](a: val->T): Bool =>
false
class val Cons[A] is ReadSeq[val->A]
"""
A list with a head and a tail, where the tail can be empty.
"""
let _size: USize
let _head: val->A
let _tail: List[A] val
new val create(a: val->A, t: List[A]) =>
_head = consume a
_tail = consume t
_size = 1 + _tail.size()
fun size(): USize =>
"""
Returns the size of the list.
"""
_size
fun apply(i: USize): val->A ? =>
"""
Returns the i-th element of the list. Errors if the index is out of bounds.
"""
match i
| 0 => _head
else _tail(i - 1)?
end
fun values(): Iterator[val->A]^ =>
"""
Returns an iterator over the elements of the list.
"""
object is Iterator[val->A]
var _list: List[A] box = this
fun has_next(): Bool => _list isnt Nil[A]
fun ref next(): val->A! ? => (_list = _list.tail()?).head()?
end
fun is_empty(): Bool =>
"""
Returns a Bool indicating if the list is empty.
"""
false
fun is_non_empty(): Bool =>
"""
Returns a Bool indicating if the list is non-empty.
"""
true
fun head(): val->A =>
"""
Returns the head of the list.
"""
_head
fun tail(): List[A] =>
"""
Returns the tail of the list.
"""
_tail
fun val reverse(): List[A] =>
"""
Builds a new list by reversing the elements in the list.
"""
_reverse(this, Nil[A])
fun val _reverse(l: List[A], acc: List[A]): List[A] =>
"""
Private helper for reverse, recursively working on elements.
"""
match l
| let cons: Cons[A] => _reverse(cons.tail(), acc.prepend(cons.head()))
else
acc
end
fun val prepend(a: val->A!): Cons[A] =>
"""
Builds a new list with an element added to the front of this list.
"""
Cons[A](consume a, this)
fun val concat(l: List[A]): List[A] =>
"""
Builds a new list that is the concatenation of this list and the provided
list.
"""
_concat(l, this.reverse())
fun val _concat(l: List[A], acc: List[A]): List[A] =>
"""
Private helper for concat that recursively builds the new list.
"""
match l
| let cons: Cons[A] => _concat(cons.tail(), acc.prepend(cons.head()))
else
acc.reverse()
end
fun val map[B](f: {(val->A): val->B} box): List[B] =>
"""
Builds a new list by applying a function to every member of the list.
"""
_map[B](this, f, Nil[B])
fun _map[B](l: List[A], f: {(val->A): val->B} box, acc: List[B]): List[B] =>
"""
Private helper for map, recursively applying function to elements.
"""
match l
| let cons: Cons[A] =>
_map[B](cons.tail(), f, acc.prepend(f(cons.head())))
else
acc.reverse()
end
fun val flat_map[B](f: {(val->A): List[B]} box): List[B] =>
"""
Builds a new list by applying a function to every member of the list and
using the elements of the resulting lists.
"""
_flat_map[B](this, f, Nil[B])
fun _flat_map[B](l: List[A], f: {(val->A): List[B]} box, acc: List[B]):
List[B] =>
"""
Private helper for flat_map, recursively working on elements.
"""
match l
| let cons: Cons[A] =>
_flat_map[B](cons.tail(), f, _rev_prepend[B](f(cons.head()), acc))
else
acc.reverse()
end
fun tag _rev_prepend[B](l: List[B], target: List[B]): List[B] =>
"""
Prepends l in reverse order onto target
"""
match l
| let cns: Cons[B] =>
_rev_prepend[B](cns.tail(), target.prepend(cns.head()))
else
target
end
fun val for_each(f: {(val->A)} box) =>
"""
Applies the supplied function to every element of the list in order.
"""
_for_each(this, f)
fun _for_each(l: List[A], f: {(val->A)} box) =>
"""
Private helper for for_each, recursively working on elements.
"""
match l
| let cons: Cons[A] =>
f(cons.head())
_for_each(cons.tail(), f)
end
fun val filter(f: {(val->A): Bool} box): List[A] =>
"""
Builds a new list with those elements that satisfy a provided predicate.
"""
_filter(this, f, Nil[A])
fun _filter(l: List[A], f: {(val->A): Bool} box, acc: List[A]): List[A] =>
"""
Private helper for filter, recursively working on elements, keeping those
that match the predicate and discarding those that don't.
"""
match l
| let cons: Cons[A] =>
if (f(cons.head())) then
_filter(cons.tail(), f, acc.prepend(cons.head()))
else
_filter(cons.tail(), f, acc)
end
else
acc.reverse()
end
fun val fold[B](f: {(B, val->A): B^} box, acc: B): B =>
"""
Folds the elements of the list using the supplied function.
"""
_fold[B](this, f, consume acc)
fun val _fold[B](l: List[A], f: {(B, val->A): B^} box, acc: B): B =>
"""
Private helper for fold, recursively working on elements.
"""
match l
| let cons: Cons[A] =>
_fold[B](cons.tail(), f, f(consume acc, cons.head()))
else
acc
end
fun val every(f: {(val->A): Bool} box): Bool =>
"""
Returns true if every element satisfies the provided predicate, false
otherwise.
"""
_every(this, f)
fun _every(l: List[A], f: {(val->A): Bool} box): Bool =>
"""
Private helper for every, recursively testing predicate on elements,
returning false immediately on an element that fails to satisfy the
predicate.
"""
match l
| let cons: Cons[A] =>
if (f(cons.head())) then
_every(cons.tail(), f)
else
false
end
else
true
end
fun val exists(f: {(val->A): Bool} box): Bool =>
"""
Returns true if at least one element satisfies the provided predicate,
false otherwise.
"""
_exists(this, f)
fun _exists(l: List[A], f: {(val->A): Bool} box): Bool =>
"""
Private helper for exists, recursively testing predicate on elements,
returning true immediately on an element satisfying the predicate.
"""
match l
| let cons: Cons[A] =>
if (f(cons.head())) then
true
else
_exists(cons.tail(), f)
end
else
false
end
fun val partition(f: {(val->A): Bool} box): (List[A], List[A]) =>
"""
Builds a pair of lists, the first of which is made up of the elements
satisfying the supplied predicate and the second of which is made up of
those that do not.
"""
var hits: List[A] = Nil[A]
var misses: List[A] = Nil[A]
var cur: List[A] = this
while true do
match cur
| let cons: Cons[A] =>
let next = cons.head()
if f(next) then
hits = hits.prepend(next)
else
misses = misses.prepend(next)
end
cur = cons.tail()
else
break
end
end
(hits.reverse(), misses.reverse())
fun val drop(n: USize): List[A] =>
"""
Builds a list by dropping the first n elements.
"""
var cur: List[A] = this
if cur.size() <= n then return Nil[A] end
var count = n
while count > 0 do
match cur
| let cons: Cons[A] =>
cur = cons.tail()
count = count - 1
end
end
cur
fun val drop_while(f: {(val->A): Bool} box): List[A] =>
"""
Builds a list by dropping elements from the front of the list until one
fails to satisfy the provided predicate.
"""
var cur: List[A] = this
while true do
match cur
| let cons: Cons[A] =>
if f(cons.head()) then cur = cons.tail() else break end
else
return Nil[A]
end
end
cur
fun val take(n: USize): List[A] =>
"""
Builds a list of the first n elements.
"""
var cur: List[A] = this
if cur.size() <= n then return cur end
var count = n
var res: List[A] = Nil[A]
while count > 0 do
match cur
| let cons: Cons[A] =>
res = res.prepend(cons.head())
cur = cons.tail()
else
return res.reverse()
end
count = count - 1
end
res.reverse()
fun val take_while(f: {(val->A): Bool} box): List[A] =>
"""
Builds a list of elements satisfying the provided predicate until one does
not.
"""
var cur: List[A] = this
var res: List[A] = Nil[A]
while true do
match cur
| let cons: Cons[A] =>
if f(cons.head()) then
res = res.prepend(cons.head())
cur = cons.tail()
else
break
end
else
return res.reverse()
end
end
res.reverse()
| pony | 4228988 | https://sv.wikipedia.org/wiki/Agave%20subsimplex | Agave subsimplex | Agave subsimplex är en sparrisväxtart som beskrevs av William Trelease. Agave subsimplex ingår i släktet Agave och familjen sparrisväxter. Inga underarter finns listade i Catalogue of Life.
Källor
Sparrisväxter
subsimplex | swedish | 1.107628 |
Pony/src-pony_test-test_list-.txt |
test_list.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17trait TestList
"""
Source of unit tests for a PonyTest object.
See package doc string for further information and example use.
"""
fun tag tests(test: PonyTest)
"""
Add all the tests in this suite to the given test object.
Typically the implementation of this function will be of the form:
```pony
fun tests(test: PonyTest) =>
test(_TestClass1)
test(_TestClass2)
test(_TestClass3)
```
"""
| pony | 3686447 | https://sv.wikipedia.org/wiki/Phyllodytesius | Phyllodytesius | Phyllodytesius är ett släkte av skalbaggar. Phyllodytesius ingår i familjen vivlar.
Kladogram enligt Catalogue of Life:
Källor
Externa länkar
Vivlar
Phyllodytesius | swedish | 1.599016 |
Pony/pony_check-IntPairUnitTest-.txt |
IntPairUnitTest¶
[Source]
type IntPairUnitTest is
Property1UnitTest[IntPairPropertySample ref] iso
Type Alias For¶
Property1UnitTest[IntPairPropertySample ref] iso
| pony | 3020586 | https://sv.wikipedia.org/wiki/Euphumosia%20tesselata | Euphumosia tesselata | Euphumosia tesselata är en tvåvingeart som beskrevs av Torgerson och James 1967. Euphumosia tesselata ingår i släktet Euphumosia och familjen spyflugor. Inga underarter finns listade i Catalogue of Life.
Källor
Spyflugor
tesselata | swedish | 1.202707 |
Pony/builtin-U32-.txt |
U32¶
[Source]
primitive val U32 is
UnsignedInteger[U32 val] val
Implements¶
UnsignedInteger[U32 val] val
Constructors¶
create¶
[Source]
new val create(
value: U32 val)
: U32 val^
Parameters¶
value: U32 val
Returns¶
U32 val^
from[A: ((I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val | F32 val | F64 val) & Real[A] val)]¶
[Source]
new val from[A: ((I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val | F32 val |
F64 val) & Real[A] val)](
a: A)
: U32 val^
Parameters¶
a: A
Returns¶
U32 val^
min_value¶
[Source]
new val min_value()
: U32 val^
Returns¶
U32 val^
max_value¶
[Source]
new val max_value()
: U32 val^
Returns¶
U32 val^
Public Functions¶
next_pow2¶
[Source]
fun box next_pow2()
: U32 val
Returns¶
U32 val
abs¶
[Source]
fun box abs()
: U32 val
Returns¶
U32 val
bit_reverse¶
[Source]
fun box bit_reverse()
: U32 val
Returns¶
U32 val
bswap¶
[Source]
fun box bswap()
: U32 val
Returns¶
U32 val
popcount¶
[Source]
fun box popcount()
: U32 val
Returns¶
U32 val
clz¶
[Source]
fun box clz()
: U32 val
Returns¶
U32 val
ctz¶
[Source]
fun box ctz()
: U32 val
Returns¶
U32 val
clz_unsafe¶
[Source]
Unsafe operation.
If this is 0, the result is undefined.
fun box clz_unsafe()
: U32 val
Returns¶
U32 val
ctz_unsafe¶
[Source]
Unsafe operation.
If this is 0, the result is undefined.
fun box ctz_unsafe()
: U32 val
Returns¶
U32 val
bitwidth¶
[Source]
fun box bitwidth()
: U32 val
Returns¶
U32 val
bytewidth¶
[Source]
fun box bytewidth()
: USize val
Returns¶
USize val
min¶
[Source]
fun box min(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
max¶
[Source]
fun box max(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
addc¶
[Source]
fun box addc(
y: U32 val)
: (U32 val , Bool val)
Parameters¶
y: U32 val
Returns¶
(U32 val , Bool val)
subc¶
[Source]
fun box subc(
y: U32 val)
: (U32 val , Bool val)
Parameters¶
y: U32 val
Returns¶
(U32 val , Bool val)
mulc¶
[Source]
fun box mulc(
y: U32 val)
: (U32 val , Bool val)
Parameters¶
y: U32 val
Returns¶
(U32 val , Bool val)
divc¶
[Source]
fun box divc(
y: U32 val)
: (U32 val , Bool val)
Parameters¶
y: U32 val
Returns¶
(U32 val , Bool val)
remc¶
[Source]
fun box remc(
y: U32 val)
: (U32 val , Bool val)
Parameters¶
y: U32 val
Returns¶
(U32 val , Bool val)
add_partial¶
[Source]
fun box add_partial(
y: U32 val)
: U32 val ?
Parameters¶
y: U32 val
Returns¶
U32 val ?
sub_partial¶
[Source]
fun box sub_partial(
y: U32 val)
: U32 val ?
Parameters¶
y: U32 val
Returns¶
U32 val ?
mul_partial¶
[Source]
fun box mul_partial(
y: U32 val)
: U32 val ?
Parameters¶
y: U32 val
Returns¶
U32 val ?
div_partial¶
[Source]
fun box div_partial(
y: U32 val)
: U32 val ?
Parameters¶
y: U32 val
Returns¶
U32 val ?
rem_partial¶
[Source]
fun box rem_partial(
y: U32 val)
: U32 val ?
Parameters¶
y: U32 val
Returns¶
U32 val ?
divrem_partial¶
[Source]
fun box divrem_partial(
y: U32 val)
: (U32 val , U32 val) ?
Parameters¶
y: U32 val
Returns¶
(U32 val , U32 val) ?
shl¶
[Source]
fun box shl(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
shr¶
[Source]
fun box shr(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
fld¶
[Source]
fun box fld(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
fldc¶
[Source]
fun box fldc(
y: U32 val)
: (U32 val , Bool val)
Parameters¶
y: U32 val
Returns¶
(U32 val , Bool val)
fld_partial¶
[Source]
fun box fld_partial(
y: U32 val)
: U32 val ?
Parameters¶
y: U32 val
Returns¶
U32 val ?
fld_unsafe¶
[Source]
fun box fld_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
mod¶
[Source]
fun box mod(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
modc¶
[Source]
fun box modc(
y: U32 val)
: (U32 val , Bool val)
Parameters¶
y: U32 val
Returns¶
(U32 val , Bool val)
mod_partial¶
[Source]
fun box mod_partial(
y: U32 val)
: U32 val ?
Parameters¶
y: U32 val
Returns¶
U32 val ?
mod_unsafe¶
[Source]
fun box mod_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
shl_unsafe¶
[Source]
fun box shl_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
shr_unsafe¶
[Source]
fun box shr_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
rotl¶
[Source]
fun box rotl(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
rotr¶
[Source]
fun box rotr(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
string¶
[Source]
fun box string()
: String iso^
Returns¶
String iso^
add_unsafe¶
[Source]
fun box add_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
sub_unsafe¶
[Source]
fun box sub_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
mul_unsafe¶
[Source]
fun box mul_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
div_unsafe¶
[Source]
fun box div_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
divrem_unsafe¶
[Source]
fun box divrem_unsafe(
y: U32 val)
: (U32 val , U32 val)
Parameters¶
y: U32 val
Returns¶
(U32 val , U32 val)
rem_unsafe¶
[Source]
fun box rem_unsafe(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
neg_unsafe¶
[Source]
fun box neg_unsafe()
: U32 val
Returns¶
U32 val
op_and¶
[Source]
fun box op_and(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
op_or¶
[Source]
fun box op_or(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
op_xor¶
[Source]
fun box op_xor(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
op_not¶
[Source]
fun box op_not()
: U32 val
Returns¶
U32 val
add¶
[Source]
fun box add(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
sub¶
[Source]
fun box sub(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
mul¶
[Source]
fun box mul(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
div¶
[Source]
fun box div(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
divrem¶
[Source]
fun box divrem(
y: U32 val)
: (U32 val , U32 val)
Parameters¶
y: U32 val
Returns¶
(U32 val , U32 val)
rem¶
[Source]
fun box rem(
y: U32 val)
: U32 val
Parameters¶
y: U32 val
Returns¶
U32 val
neg¶
[Source]
fun box neg()
: U32 val
Returns¶
U32 val
eq¶
[Source]
fun box eq(
y: U32 val)
: Bool val
Parameters¶
y: U32 val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
y: U32 val)
: Bool val
Parameters¶
y: U32 val
Returns¶
Bool val
lt¶
[Source]
fun box lt(
y: U32 val)
: Bool val
Parameters¶
y: U32 val
Returns¶
Bool val
le¶
[Source]
fun box le(
y: U32 val)
: Bool val
Parameters¶
y: U32 val
Returns¶
Bool val
ge¶
[Source]
fun box ge(
y: U32 val)
: Bool val
Parameters¶
y: U32 val
Returns¶
Bool val
gt¶
[Source]
fun box gt(
y: U32 val)
: Bool val
Parameters¶
y: U32 val
Returns¶
Bool val
hash¶
[Source]
fun box hash()
: USize val
Returns¶
USize val
hash64¶
[Source]
fun box hash64()
: U64 val
Returns¶
U64 val
i8¶
[Source]
fun box i8()
: I8 val
Returns¶
I8 val
i16¶
[Source]
fun box i16()
: I16 val
Returns¶
I16 val
i32¶
[Source]
fun box i32()
: I32 val
Returns¶
I32 val
i64¶
[Source]
fun box i64()
: I64 val
Returns¶
I64 val
i128¶
[Source]
fun box i128()
: I128 val
Returns¶
I128 val
ilong¶
[Source]
fun box ilong()
: ILong val
Returns¶
ILong val
isize¶
[Source]
fun box isize()
: ISize val
Returns¶
ISize val
u8¶
[Source]
fun box u8()
: U8 val
Returns¶
U8 val
u16¶
[Source]
fun box u16()
: U16 val
Returns¶
U16 val
u32¶
[Source]
fun box u32()
: U32 val
Returns¶
U32 val
u64¶
[Source]
fun box u64()
: U64 val
Returns¶
U64 val
u128¶
[Source]
fun box u128()
: U128 val
Returns¶
U128 val
ulong¶
[Source]
fun box ulong()
: ULong val
Returns¶
ULong val
usize¶
[Source]
fun box usize()
: USize val
Returns¶
USize val
f32¶
[Source]
fun box f32()
: F32 val
Returns¶
F32 val
f64¶
[Source]
fun box f64()
: F64 val
Returns¶
F64 val
i8_unsafe¶
[Source]
fun box i8_unsafe()
: I8 val
Returns¶
I8 val
i16_unsafe¶
[Source]
fun box i16_unsafe()
: I16 val
Returns¶
I16 val
i32_unsafe¶
[Source]
fun box i32_unsafe()
: I32 val
Returns¶
I32 val
i64_unsafe¶
[Source]
fun box i64_unsafe()
: I64 val
Returns¶
I64 val
i128_unsafe¶
[Source]
fun box i128_unsafe()
: I128 val
Returns¶
I128 val
ilong_unsafe¶
[Source]
fun box ilong_unsafe()
: ILong val
Returns¶
ILong val
isize_unsafe¶
[Source]
fun box isize_unsafe()
: ISize val
Returns¶
ISize val
u8_unsafe¶
[Source]
fun box u8_unsafe()
: U8 val
Returns¶
U8 val
u16_unsafe¶
[Source]
fun box u16_unsafe()
: U16 val
Returns¶
U16 val
u32_unsafe¶
[Source]
fun box u32_unsafe()
: U32 val
Returns¶
U32 val
u64_unsafe¶
[Source]
fun box u64_unsafe()
: U64 val
Returns¶
U64 val
u128_unsafe¶
[Source]
fun box u128_unsafe()
: U128 val
Returns¶
U128 val
ulong_unsafe¶
[Source]
fun box ulong_unsafe()
: ULong val
Returns¶
ULong val
usize_unsafe¶
[Source]
fun box usize_unsafe()
: USize val
Returns¶
USize val
f32_unsafe¶
[Source]
fun box f32_unsafe()
: F32 val
Returns¶
F32 val
f64_unsafe¶
[Source]
fun box f64_unsafe()
: F64 val
Returns¶
F64 val
compare¶
[Source]
fun box compare(
that: U32 val)
: (Less val | Equal val | Greater val)
Parameters¶
that: U32 val
Returns¶
(Less val | Equal val | Greater val)
| pony | 4017926 | https://sv.wikipedia.org/wiki/Gunnar%20%28runristare%29 | Gunnar (runristare) | Gunnar var en uppländsk runristare som var verksam under tusentalets första hälft. Hans ornamentik med kopplade slingor och naivt tilltrubbade ormhuvuden går i en typisk Ringerikestil: Pr1-Pr2. En del av hans runormar är dock huvudlösa och slingorna löper i flera varv runt ett i regel stort och prydligt kors. Många av hans välarbetade inskrifter har dessutom fått en versifierad form.
Gunnar anses vara upphovsmannen bakom minst 27 olika runstenar belägna i Bro, Lyhundra, Orkesta, Skederids, Spånga, Täby, Vallentuna och Össeby-Garns socknar.
Hans signatur är: "Kunar ik stin", med betydelsen "Gunnar högg stenen", vilket står på U 226, en minnessten som restes på Arkils då nyanlagda tingsplats i Bällsta, Vallentuna socken.
Signerade inskrifter
parstenar U 225 och U 226, den sista är signerad: kunar ik stin
Attribuerade inskrifter
U 61
U 69
U 103
U 160
U 161
U 169
U 186
U 187
U 188
U 189
U 200
U 201
U 221
U 224
U 225
U 258
U 276
U 319
U 323
U 326
U 327
U 328
U 336
U 338
U 341
U 349
U 355
U 358
U 371
U 430
U 490
U 502
U 504
U 508
U 512
U 518
U 539
U 586
U 587
U 617
U 785
U Fv1979;244B
Se även
Lista över runristare
Runristning
Källor
Fornnordiskt lexikon, sid. 122, sammanställt av Åke Ohlmarks, Tiden, 1983,
Noter
Runristare
Personer i Sverige under 1000-talet | swedish | 0.875983 |
Pony/src-cli-command-.txt |
command.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194use "collections"
class box Command
"""
Command contains all of the information describing a command with its spec
and effective options and arguments, ready to use.
"""
let _spec: CommandSpec box
let _fullname: String
let _options: Map[String, Option] box
let _args: Map[String, Arg] box
new _create(
spec': CommandSpec box,
fullname': String,
options': Map[String, Option] box,
args': Map[String, Arg] box)
=>
_spec = spec'
_fullname = fullname'
_options = options'
_args = args'
fun string(): String iso^ =>
"""
Returns a representational string for this command.
"""
let s: String iso = fullname().clone()
for o in _options.values() do
s.append(" ")
s.append(o.deb_string())
end
for a in _args.values() do
s.append(" ")
s.append(a.deb_string())
end
s
fun spec() : CommandSpec box =>
"""
Returns the spec for this command.
"""
_spec
fun fullname() : String =>
"""
Returns the full name of this command, with its parents prefixed.
"""
_fullname
fun option(name: String): Option =>
"""
Returns the Option by name, defaulting to a fake Option if unknown.
"""
try _options(name)? else Option(OptionSpec.bool(name), false) end
fun arg(name: String): Arg =>
"""
Returns the Arg by name, defaulting to a fake Arg if unknown.
"""
try _args(name)? else Arg(ArgSpec.bool(name), false) end
class val Option
"""
Option contains a spec and an effective value for a given option.
"""
let _spec: OptionSpec
let _value: _Value
new val create(spec': OptionSpec, value': _Value) =>
_spec = spec'
_value = value'
fun _append(next: Option): Option =>
Option(_spec, _spec._typ_p().append(_value, next._value))
fun spec() : OptionSpec => _spec
fun bool(): Bool =>
"""
Returns the option value as a Bool, defaulting to false.
"""
try _value as Bool else false end
fun string(): String =>
"""
Returns the option value as a String, defaulting to empty.
"""
try _value as String else "" end
fun i64(): I64 =>
"""
Returns the option value as an I64, defaulting to 0.
"""
try _value as I64 else I64(0) end
fun u64(): U64 =>
"""
Returns the option value as an U64, defaulting to 0.
"""
try _value as U64 else U64(0) end
fun f64(): F64 =>
"""
Returns the option value as an F64, defaulting to 0.0.
"""
try _value as F64 else F64(0) end
fun string_seq(): ReadSeq[String] val =>
"""
Returns the option value as a ReadSeq[String], defaulting to empty.
"""
try
_value as _StringSeq val
else
recover val Array[String]() end
end
fun deb_string(): String =>
_spec.deb_string() + "=" + _value.string()
class val Arg
"""
Arg contains a spec and an effective value for a given arg.
"""
let _spec: ArgSpec
let _value: _Value
new val create(spec': ArgSpec, value': _Value) =>
_spec = spec'
_value = value'
fun _append(next: Arg): Arg =>
Arg(_spec, _spec._typ_p().append(_value, next._value))
fun spec(): ArgSpec => _spec
fun bool(): Bool =>
"""
Returns the arg value as a Bool, defaulting to false.
"""
try _value as Bool else false end
fun string(): String =>
"""
Returns the arg value as a String, defaulting to empty.
"""
try _value as String else "" end
fun i64(): I64 =>
"""
Returns the arg value as an I64, defaulting to 0.
"""
try _value as I64 else I64(0) end
fun u64(): U64 =>
"""
Returns the arg value as an U64, defaulting to 0.
"""
try _value as U64 else U64(0) end
fun f64(): F64 =>
"""
Returns the arg value as an F64, defaulting to 0.0.
"""
try _value as F64 else F64(0) end
fun string_seq(): ReadSeq[String] val =>
"""
Returns the arg value as a ReadSeq[String], defaulting to empty.
"""
try
_value as _StringSeq val
else
recover val Array[String]() end
end
fun deb_string(): String =>
"(" + _spec.deb_string() + "=)" + _value.string()
class val SyntaxError
"""
SyntaxError summarizes a syntax error in a given parsed command line.
"""
let _token: String
let _msg: String
new val create(token': String, msg': String) =>
_token = token'
_msg = msg'
fun token(): String => _token
fun string(): String => "Error: " + _msg + " at: '" + _token + "'"
| pony | 884448 | https://sv.wikipedia.org/wiki/Pandora%20%28spelkonsol%29 | Pandora (spelkonsol) | Pandora är en bärbar spelkonsol som utvecklas av användare från gp32x forum. Enheten lanserades under 2010 och levereras nu till kunder omgående. Dock uppstod det många problem i tillverkningen av de första enheterna. Detta gjorde så att enheterna inte kunde levereras på det önskade släppdatumet. Numera är enheten i massproduktion och allt fungerar felfritt. OpenPandora tillverkas numera i Tyskland av OpenPandora GmbH. På grund av att tillverkningen av enheterna sker i väldigt liten skala är konsolen betydligt dyrare i inköpspris jämfört med konkurrenterna. Tillverkaren kan inte heller kompensera priset med spelförsäljning eftersom den baseras på fri mjukvara. Den Linuxbaserade konsolen baseras på ett systemchip från Texas Instruments.
Hårdvara
Texas Instruments OMAP3530 processor på 600 MHz (utvecklare hävdar att den ska gå att överklocka till 900 MHz)
256MB DDR-333 SDRAM (numera är alla nya enheter som levereras utrustade med 512 MB RAM)
512MB NAND FLASH memory (ändrades i ett sent skede från 256MB, delvis som kompensation för att det blev en del problem med betalningarna av de första förhandsbokningarna)
IVA2+ ljud och video processor (baserad på TMS320C64x+ DSP Core på 430 MHz)
ARM Cortex-A8 superscalar microprocessor core
PowerVR SGX 530 (110 MHz) OpenGL ES 2.0 kompatibelt
Integrerad Wi-Fi 802.11b/g
Integrerad Bluetooth 2.0 + EDR (3Mbit/s) (Class 2, +4dBm)
800x480 upplösning touchscreen LCD, 4.3" widescreen, 16.7 million colors (300 cd/m2 Luminans(ljusstyrka), 450:1 kontrast)
4000mAH uppladdningsbara Litiumjonbatteri batteri (ca 10 timmars filmuppspelning och ca 100 timmar för musik. Beroende på klockfrekvensen så kan denna uppgift ändras)
TV output (S-Video)
Hörlurs uttag upp till 150 mW/kanal i 16 ohm, 99dB SNR
integrerad mikrofon plus möjlighet att koppla in extern via headset
Två SDHC kortplatser (upp till 64GB lagringsutrymme just nu)
43 knappars QWERTY och siffrig knappsats
Dubbla analoga nubs, 15mm diameter, konkav, 2 mm resa från centrum
Gamepad kontroller plus axel knappar
USB 2.0 uttag (480MB/s) Med möjlighet att ladda Pandoran
Storlek: 140 × 83 × 27mm
Se även
GP2X
Referenser
Externa länkar
Pandoras officiella webbplats
Pandora Wiki
Handhållna spelkonsoler | swedish | 0.989264 |
Pony/src-buffered-reader-.txt |
reader.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797use "collections"
class Reader
"""
Store network data and provide a parsing interface.
`Reader` provides a way to extract typed data from a sequence of
bytes. The `Reader` manages the underlying data structures to
provide a read cursor over a contiguous sequence of bytes. It is
useful for decoding data that is received over a network or stored
in a file. Chunk of bytes are added to the `Reader` using the
`append` method, and typed data is extracted using the getter
methods.
For example, suppose we have a UDP-based network data protocol where
messages consist of the following:
* `list_size` - the number of items in the following list of items
as a big-endian 32-bit integer
* zero or more items of the following data:
* a big-endian 64-bit floating point number
* a string that starts with a big-endian 32-bit integer that
specifies the length of the string, followed by a number of
bytes that represent the string
A message would be something like this:
```
[message_length][list_size][float1][string1][float2][string2]...
```
The following program uses a `Reader` to decode a message of
this type and print them:
```pony
use "buffered"
use "collections"
class Notify is InputNotify
let _env: Env
new create(env: Env) =>
_env = env
fun ref apply(data: Array[U8] iso) =>
let rb = Reader
rb.append(consume data)
try
while true do
let len = rb.i32_be()?
let items = rb.i32_be()?.usize()
for range in Range(0, items) do
let f = rb.f32_be()?
let str_len = rb.i32_be()?.usize()
let str = String.from_array(rb.block(str_len)?)
_env.out.print("[(" + f.string() + "), (" + str + ")]")
end
end
end
actor Main
new create(env: Env) =>
env.input(recover Notify(env) end, 1024)
```
"""
embed _chunks: List[(Array[U8] val, USize)] = _chunks.create()
var _available: USize = 0
fun size(): USize =>
"""
Return the number of available bytes.
"""
_available
fun ref clear() =>
"""
Discard all pending data.
"""
_chunks.clear()
_available = 0
fun ref append(data: ByteSeq) =>
"""
Add a chunk of data.
"""
let data_array =
match data
| let data': Array[U8] val => data'
| let data': String => data'.array()
end
_available = _available + data_array.size()
_chunks.push((data_array, 0))
fun ref skip(n: USize) ? =>
"""
Skip n bytes.
"""
if _available >= n then
_available = _available - n
var rem = n
while rem > 0 do
let node = _chunks.head()?
(var data, var offset) = node()?
let avail = data.size() - offset
if avail > rem then
node()? = (data, offset + rem)
break
end
rem = rem - avail
_chunks.shift()?
end
else
error
end
fun ref block(len: USize): Array[U8] iso^ ? =>
"""
Return a block as a contiguous chunk of memory.
Will throw an error if you request a block larger than what is currently
stored in the `Reader`.
"""
if _available < len then
error
end
_available = _available - len
var out = recover Array[U8] .> undefined(len) end
var i = USize(0)
while i < len do
let node = _chunks.head()?
(let data, let offset) = node()?
let avail = data.size() - offset
let need = len - i
let copy_len = need.min(avail)
out = recover
let r = consume ref out
data.copy_to(r, offset, i, copy_len)
consume r
end
if avail > need then
node()? = (data, offset + need)
break
end
i = i + copy_len
_chunks.shift()?
end
out
fun ref read_until(separator: U8): Array[U8] iso^ ? =>
"""
Find the first occurrence of the separator and return the block of bytes
before its position. The separator is not included in the returned array,
but it is removed from the buffer. To read a line of text, prefer line()
that handles \n and \r\n.
"""
let b = block(_distance_of(separator)? - 1)?
u8()?
b
fun ref line(keep_line_breaks: Bool = false): String iso^ ? =>
"""
Return a \n or \r\n terminated line as a string. By default the newline is not
included in the returned string, but it is removed from the buffer.
Set `keep_line_breaks` to `true` to keep the line breaks in the returned line.
"""
let len = _search_length()?
_available = _available - len
var out = recover String(len) end
var i = USize(0)
while i < len do
let node = _chunks.head()?
(let data, let offset) = node()?
let avail = data.size() - offset
let need = len - i
let copy_len = need.min(avail)
out.append(data, offset, copy_len)
if avail > need then
node()? = (data, offset + need)
break
end
i = i + copy_len
_chunks.shift()?
end
let trunc_len: USize =
if keep_line_breaks then
0
elseif (len >= 2) and (out.at_offset(-2)? == '\r') then
2
else
1
end
out.truncate(len - trunc_len)
consume out
fun ref u8(): U8 ? =>
"""
Get a U8. Raise an error if there isn't enough data.
"""
if _available >= 1 then
_byte()?
else
error
end
fun ref i8(): I8 ? =>
"""
Get an I8.
"""
u8()?.i8()
fun ref u16_be(): U16 ? =>
"""
Get a big-endian U16.
"""
let num_bytes = U16(0).bytewidth()
if _available >= num_bytes then
let node = _chunks.head()?
(var data, var offset) = node()?
if (data.size() - offset) >= num_bytes then
let r =
ifdef bigendian then
data.read_u16(offset)?
else
data.read_u16(offset)?.bswap()
end
offset = offset + num_bytes
_available = _available - num_bytes
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
else
// single array did not have all the bytes needed
(u8()?.u16() << 8) or u8()?.u16()
end
else
error
end
fun ref u16_le(): U16 ? =>
"""
Get a little-endian U16.
"""
let num_bytes = U16(0).bytewidth()
if _available >= num_bytes then
let node = _chunks.head()?
(var data, var offset) = node()?
if (data.size() - offset) >= num_bytes then
let r =
ifdef littleendian then
data.read_u16(offset)?
else
data.read_u16(offset)?.bswap()
end
offset = offset + num_bytes
_available = _available - num_bytes
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
else
// single array did not have all the bytes needed
u8()?.u16() or (u8()?.u16() << 8)
end
else
error
end
fun ref i16_be(): I16 ? =>
"""
Get a big-endian I16.
"""
u16_be()?.i16()
fun ref i16_le(): I16 ? =>
"""
Get a little-endian I16.
"""
u16_le()?.i16()
fun ref u32_be(): U32 ? =>
"""
Get a big-endian U32.
"""
let num_bytes = U32(0).bytewidth()
if _available >= num_bytes then
let node = _chunks.head()?
(var data, var offset) = node()?
if (data.size() - offset) >= num_bytes then
let r =
ifdef bigendian then
data.read_u32(offset)?
else
data.read_u32(offset)?.bswap()
end
offset = offset + num_bytes
_available = _available - num_bytes
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
else
// single array did not have all the bytes needed
(u8()?.u32() << 24) or (u8()?.u32() << 16) or
(u8()?.u32() << 8) or u8()?.u32()
end
else
error
end
fun ref u32_le(): U32 ? =>
"""
Get a little-endian U32.
"""
let num_bytes = U32(0).bytewidth()
if _available >= num_bytes then
let node = _chunks.head()?
(var data, var offset) = node()?
if (data.size() - offset) >= num_bytes then
let r =
ifdef littleendian then
data.read_u32(offset)?
else
data.read_u32(offset)?.bswap()
end
offset = offset + num_bytes
_available = _available - num_bytes
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
else
// single array did not have all the bytes needed
u8()?.u32() or (u8()?.u32() << 8) or
(u8()?.u32() << 16) or (u8()?.u32() << 24)
end
else
error
end
fun ref i32_be(): I32 ? =>
"""
Get a big-endian I32.
"""
u32_be()?.i32()
fun ref i32_le(): I32 ? =>
"""
Get a little-endian I32.
"""
u32_le()?.i32()
fun ref u64_be(): U64 ? =>
"""
Get a big-endian U64.
"""
let num_bytes = U64(0).bytewidth()
if _available >= num_bytes then
let node = _chunks.head()?
(var data, var offset) = node()?
if (data.size() - offset) >= num_bytes then
let r =
ifdef bigendian then
data.read_u64(offset)?
else
data.read_u64(offset)?.bswap()
end
offset = offset + num_bytes
_available = _available - num_bytes
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
else
// single array did not have all the bytes needed
(u8()?.u64() << 56) or (u8()?.u64() << 48) or
(u8()?.u64() << 40) or (u8()?.u64() << 32) or
(u8()?.u64() << 24) or (u8()?.u64() << 16) or
(u8()?.u64() << 8) or u8()?.u64()
end
else
error
end
fun ref u64_le(): U64 ? =>
"""
Get a little-endian U64.
"""
let num_bytes = U64(0).bytewidth()
if _available >= num_bytes then
let node = _chunks.head()?
(var data, var offset) = node()?
if (data.size() - offset) >= num_bytes then
let r =
ifdef littleendian then
data.read_u64(offset)?
else
data.read_u64(offset)?.bswap()
end
offset = offset + num_bytes
_available = _available - num_bytes
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
else
// single array did not have all the bytes needed
u8()?.u64() or (u8()?.u64() << 8) or
(u8()?.u64() << 16) or (u8()?.u64() << 24) or
(u8()?.u64() << 32) or (u8()?.u64() << 40) or
(u8()?.u64() << 48) or (u8()?.u64() << 56)
end
else
error
end
fun ref i64_be(): I64 ? =>
"""
Get a big-endian I64.
"""
u64_be()?.i64()
fun ref i64_le(): I64 ? =>
"""
Get a little-endian I64.
"""
u64_le()?.i64()
fun ref u128_be(): U128 ? =>
"""
Get a big-endian U128.
"""
let num_bytes = U128(0).bytewidth()
if _available >= num_bytes then
let node = _chunks.head()?
(var data, var offset) = node()?
if (data.size() - offset) >= num_bytes then
let r =
ifdef bigendian then
data.read_u128(offset)?
else
data.read_u128(offset)?.bswap()
end
offset = offset + num_bytes
_available = _available - num_bytes
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
else
// single array did not have all the bytes needed
(u8()?.u128() << 120) or (u8()?.u128() << 112) or
(u8()?.u128() << 104) or (u8()?.u128() << 96) or
(u8()?.u128() << 88) or (u8()?.u128() << 80) or
(u8()?.u128() << 72) or (u8()?.u128() << 64) or
(u8()?.u128() << 56) or (u8()?.u128() << 48) or
(u8()?.u128() << 40) or (u8()?.u128() << 32) or
(u8()?.u128() << 24) or (u8()?.u128() << 16) or
(u8()?.u128() << 8) or u8()?.u128()
end
else
error
end
fun ref u128_le(): U128 ? =>
"""
Get a little-endian U128.
"""
let num_bytes = U128(0).bytewidth()
if _available >= num_bytes then
let node = _chunks.head()?
(var data, var offset) = node()?
if (data.size() - offset) >= num_bytes then
let r =
ifdef littleendian then
data.read_u128(offset)?
else
data.read_u128(offset)?.bswap()
end
offset = offset + num_bytes
_available = _available - num_bytes
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
else
// single array did not have all the bytes needed
u8()?.u128() or (u8()?.u128() << 8) or
(u8()?.u128() << 16) or (u8()?.u128() << 24) or
(u8()?.u128() << 32) or (u8()?.u128() << 40) or
(u8()?.u128() << 48) or (u8()?.u128() << 56) or
(u8()?.u128() << 64) or (u8()?.u128() << 72) or
(u8()?.u128() << 80) or (u8()?.u128() << 88) or
(u8()?.u128() << 96) or (u8()?.u128() << 104) or
(u8()?.u128() << 112) or (u8()?.u128() << 120)
end
else
error
end
fun ref i128_be(): I128 ? =>
"""
Get a big-endian I129.
"""
u128_be()?.i128()
fun ref i128_le(): I128 ? =>
"""
Get a little-endian I128.
"""
u128_le()?.i128()
fun ref f32_be(): F32 ? =>
"""
Get a big-endian F32.
"""
F32.from_bits(u32_be()?)
fun ref f32_le(): F32 ? =>
"""
Get a little-endian F32.
"""
F32.from_bits(u32_le()?)
fun ref f64_be(): F64 ? =>
"""
Get a big-endian F64.
"""
F64.from_bits(u64_be()?)
fun ref f64_le(): F64 ? =>
"""
Get a little-endian F64.
"""
F64.from_bits(u64_le()?)
fun ref _byte(): U8 ? =>
"""
Get a single byte.
"""
let node = _chunks.head()?
(var data, var offset) = node()?
let r = data(offset)?
offset = offset + 1
_available = _available - 1
if offset < data.size() then
node()? = (data, offset)
else
_chunks.shift()?
end
r
fun peek_u8(offset: USize = 0): U8 ? =>
"""
Peek at a U8 at the given offset. Raise an error if there isn't enough
data.
"""
_peek_byte(offset)?
fun peek_i8(offset: USize = 0): I8 ? =>
"""
Peek at an I8.
"""
peek_u8(offset)?.i8()
fun peek_u16_be(offset: USize = 0): U16 ? =>
"""
Peek at a big-endian U16.
"""
(peek_u8(offset)?.u16() << 8) or peek_u8(offset + 1)?.u16()
fun peek_u16_le(offset: USize = 0): U16 ? =>
"""
Peek at a little-endian U16.
"""
peek_u8(offset)?.u16() or (peek_u8(offset + 1)?.u16() << 8)
fun peek_i16_be(offset: USize = 0): I16 ? =>
"""
Peek at a big-endian I16.
"""
peek_u16_be(offset)?.i16()
fun peek_i16_le(offset: USize = 0): I16 ? =>
"""
Peek at a little-endian I16.
"""
peek_u16_le(offset)?.i16()
fun peek_u32_be(offset: USize = 0): U32 ? =>
"""
Peek at a big-endian U32.
"""
(peek_u16_be(offset)?.u32() << 16) or peek_u16_be(offset + 2)?.u32()
fun peek_u32_le(offset: USize = 0): U32 ? =>
"""
Peek at a little-endian U32.
"""
peek_u16_le(offset)?.u32() or (peek_u16_le(offset + 2)?.u32() << 16)
fun peek_i32_be(offset: USize = 0): I32 ? =>
"""
Peek at a big-endian I32.
"""
peek_u32_be(offset)?.i32()
fun peek_i32_le(offset: USize = 0): I32 ? =>
"""
Peek at a little-endian I32.
"""
peek_u32_le(offset)?.i32()
fun peek_u64_be(offset: USize = 0): U64 ? =>
"""
Peek at a big-endian U64.
"""
(peek_u32_be(offset)?.u64() << 32) or peek_u32_be(offset + 4)?.u64()
fun peek_u64_le(offset: USize = 0): U64 ? =>
"""
Peek at a little-endian U64.
"""
peek_u32_le(offset)?.u64() or (peek_u32_le(offset + 4)?.u64() << 32)
fun peek_i64_be(offset: USize = 0): I64 ? =>
"""
Peek at a big-endian I64.
"""
peek_u64_be(offset)?.i64()
fun peek_i64_le(offset: USize = 0): I64 ? =>
"""
Peek at a little-endian I64.
"""
peek_u64_le(offset)?.i64()
fun peek_u128_be(offset: USize = 0): U128 ? =>
"""
Peek at a big-endian U128.
"""
(peek_u64_be(offset)?.u128() << 64) or peek_u64_be(offset + 8)?.u128()
fun peek_u128_le(offset: USize = 0): U128 ? =>
"""
Peek at a little-endian U128.
"""
peek_u64_le(offset)?.u128() or (peek_u64_le(offset + 8)?.u128() << 64)
fun peek_i128_be(offset: USize = 0): I128 ? =>
"""
Peek at a big-endian I129.
"""
peek_u128_be(offset)?.i128()
fun peek_i128_le(offset: USize = 0): I128 ? =>
"""
Peek at a little-endian I128.
"""
peek_u128_le(offset)?.i128()
fun peek_f32_be(offset: USize = 0): F32 ? =>
"""
Peek at a big-endian F32.
"""
F32.from_bits(peek_u32_be(offset)?)
fun peek_f32_le(offset: USize = 0): F32 ? =>
"""
Peek at a little-endian F32.
"""
F32.from_bits(peek_u32_le(offset)?)
fun peek_f64_be(offset: USize = 0): F64 ? =>
"""
Peek at a big-endian F64.
"""
F64.from_bits(peek_u64_be(offset)?)
fun peek_f64_le(offset: USize = 0): F64 ? =>
"""
Peek at a little-endian F64.
"""
F64.from_bits(peek_u64_le(offset)?)
fun _peek_byte(offset: USize = 0): U8 ? =>
"""
Get the byte at the given offset without moving the cursor forward.
Raise an error if the given offset is not yet available.
"""
var offset' = offset
var iter = _chunks.nodes()
while true do
let node = iter.next()?
(var data, var node_offset) = node()?
offset' = offset' + node_offset
let data_size = data.size()
if offset' >= data_size then
offset' = offset' - data_size
else
return data(offset')?
end
end
error
fun ref _distance_of(byte: U8): USize ? =>
"""
Get the distance to the first occurrence of the given byte
"""
if _chunks.size() == 0 then
error
end
var node = _chunks.head()?
var search_len: USize = 0
while true do
(var data, var offset) = node()?
try
let len = (search_len + data.find(byte, offset)? + 1) - offset
search_len = 0
return len
end
search_len = search_len + (data.size() - offset)
if not node.has_next() then
break
end
node = node.next() as ListNode[(Array[U8] val, USize)]
end
error
fun ref _search_length(): USize ? =>
"""
Get the length of a pending line. Raise an error if there is no pending
line.
"""
_distance_of('\n')?
| pony | 632112 | https://da.wikipedia.org/wiki/Foretrukne%20tal | Foretrukne tal | Foretrukne tal (også kaldet foretrukne værdier) er standardanbefalinger til at vælge eksakte produktdimensioner med ens begrænsninger. I industridesign kan produktudviklere vælge mange forskellige længder, diametre, rumfang og andre karakteristiske kvantiteter. Selv om alle disse valg er begrænset af funktionalitet, brugervenlighed, kompatibilitet, sikkerhed eller omkostninger, er det sædvanligvis et stort spillerum for valg af eksakte dimensionsvalg.
Foretrukne tal tjener to hensigter:
Brug af foretrukne tal øger sandsynligheden for at andre designere vil gøre de samme valg. Dette er specielt nyttigt, hvor de valgte dimensioner påvirker kompatibilitet. Hvis for eksempel inderdiameteren til gryder eller afstanden mellem skruer i væggen er valgt fra en serie med foretrukne nummer, vil sandsynligheden for at gamle gryder og vægg-plugg-huller kan blive genbrugt, når det oprindelige produkt udskiftes.
Foretrukne tal vælges sådan at et produkt produceres i mange forskellige størrelser, så vil disse ende op som ens på en logaritmisk skala. Det vil derfor hjælpe til at minimere antallet af forskellige størrelser som må produceres og lagres.
Renard-tal
Den franske hæringeniøren Charles Renard foreslog i 1870'erne en mængde med foretrukne tal anvendt sammen med det metriske system.
Hans system blev tilpasset i 1952 som den internationale standard ISO 3. Renard's system af foretrukne tal inddeler intervallet fra 1 til 10 ind i 5, 10, 20 eller 40 trin. Faktoren mellem to fortløbende tal i en Renard-talserie (Bedre?: Renard-række) er konstant (før afrunding), nemlig den 5., 10., 20. eller 40. rod af 10 (hhv. ca. 1,58, 1,26, 1,12 og 1.06), hvilket leder til en geometrisk række. På denne måde minimeres den maksimale relative fejl hvis et vilkårligt tal erstattes af det nærmeste Renard-tal multipliceret med den passende potens af 10.
Disse tal kan afrundes til enhver vilkårlig præcision, da de er irrationelle. R5 afrundet til forskellige præcisioner:
Ettere: 1 2 3 4 6
Tiere: 1,0 1,6 2,5 4,0 6,3
Hundreder: 1,00 1,58 2,51 3,98 6,31
Eksempel: Hvis vores designrestriktioner fortæller os at de to skruer i vores gadget skal placeres mellem 32 mm og 55 mm fra hinanden, kan vi vælge at den skal være 40 mm, fordi 4 er i R5-talserien af foretrukne tal.
Eksempel: Hvis du ønsker at producere en mængde søm med længder mellem ca. 15 og 300 mm, så vil anvendelsen af R5-talserien lede til et produkt repertoire af disse sømlængder: 16 mm, 25 mm, 40 mm, 63 mm, 100 mm, 160 mm og 250 mm.
Hvis en finere opløsning er behøvet, kan yderligere fem tal tilføjes til serien, en efter hver af de originale R5-tal – og vi ender med R10-talserien:
R10: 1,00 1,25 1,60 2,00 2,50 3,15 4,00 5,00 6,30 8,00
Når en endnu finere graduering er behøvet, kan R20-, R40- og R80-talserierne anvendes:
R20: 1,00 1,25 1,60 2,00 2,50 3,15 4,00 5,00 6,30 8,00
1,12 1,40 1,80 2,24 2,80 3,55 4,50 5,60 7,10 9,00
R40: 1,00 1,25 1,60 2,00 2,50 3,15 4,00 5,00 6,30 8,00
1,06 1,32 1,70 2,12 2,65 3,35 4,25 5,30 6,70 8,50
1,12 1,40 1,80 2,24 2,80 3,55 4,50 5,60 7,10 9,00
1,18 1,50 1,90 2,36 3,00 3,75 4,75 6,00 7,50 9,50
R80: 1,00 1,25 1,60 2,00 2,50 3,15 4,00 5,00 6,30 8,00
1,03 1,28 1,65 2,06 2,58 3,25 4,12 5,15 6,50 8,25
1,06 1,32 1,70 2,12 2,65 3,35 4,25 5,30 6,70 8,50
1,09 1,36 1,75 2,18 2,72 3,45 4,37 5,45 6,90 8,75
1,12 1,40 1,80 2,24 2,80 3,55 4,50 5,60 7,10 9,00
1,15 1,45 1,85 2,30 2,90 3,65 4,62 5,80 7,30 9,25
1,18 1,50 1,90 2,36 3,00 3,75 4,75 6,00 7,50 9,50
1,22 1,55 1,95 2,43 3,07 3,87 4,87 6,15 7,75 9,75
I nogle anvendelser er mere afrundede værdier ønskelige, enten fordi tallene fra den normale serie vill underforstå en urealistisk høj nøjagtighed – eller fordi en heltalsværdi er ønskelig (f.eks., antallet af tænder på et tandhjul). For at opfylde disse behov er en mere afrundet version af Renard-talserien defineret i ISO 3:
R5″: 1 1,5 2,5 4 6
R10′: 1 1,25 1,6 2 2,5 3,2 4 5 6,3 8
R10″: 1 1,2 1,5 2 2,5 3 4 5 6 8
R20′: 1 1,25 1,6 2 2,5 3,2 4 5 6,3 8
1,1 1,4 1,8 2,2 2,8 3,6 4,5 5,6 7,1 9
R20″: 1 1,2 1,5 2 2,5 3 4 5 6 8
1,1 1,4 1,8 2,2 2,8 3,5 4,5 5,5 7 9
R40′: 1 1,25 1,6 2 2,5 3,2 4 5 6,3 8
1,05 1,3 1,7 2,1 2,6 3,4 4,2 5,3 6,7 8,5
1,1 1,4 1,8 2,2 2,8 3,6 4,5 5,6 7,1 9
1,2 1,5 1,9 2,4 3 3,8 4,8 6 7,5 9,5
Da Renard-tallene gentages efter hver 10-foldig ændring af skalaen, er de især egnet til at blive anvendt med SI-enheder. Det gør ingen forskel om Renard-tallene anvendes med meter eller kilometer.
Renard-tallene er afrundede resultater af formlen:
,
hvor b er den valgte talserie antal (for eksempel b = 40 for R40-talserien), og i er talseriens ite element (hvor i = 0 løber til i = b).
Detaljistforpakning
I nogle lande begrænser forbruger-lovgivningen antallet af forskellige forbrugerpakninger(f-pak) et givet produkt kan sælges i, for at det skal være lettere for forbrugeren at sammenligne priser.
Et eksempel på en sådan regulering er EU-direktivet, som behandler væsker (75/106/EEC). Direktivet begrænser antallet af forskellige vinflaskestørrelser til 0,1, 0,25 (2/8), 0,375 (3/8), 0,5 (4/8), 0,75 (6/8), 1, 1,5, 2, 3, and 5 liter. Tilsvarende lister findes for mange andre typer produkt.
E-serien
Indenfor elektronik definerer den internationale standard IEC 60063 en anden foretrukken talserie for resistorer, kondensatorer, spoler og zenerdioder. (historisk er den fra engelsk RMA Preferred Number Values of Fixed Composition Resistors) Talserien fungerer omtrent ligesom Renard-talserierne, undtagen at den underinddeler intervallet fra 1 til 10 ind i 6, 12, 24, osv. trin. Disse underinddelinger sikrer at når en vilkårlig værdi erstattes med den nærmeste fortrukne talværdi, er den maksimale relative fejl i omegnen af hhv. 20%, 10%, 5%, osv.
Anvendelse af E-talserierne er normalt afgrænset til resistorer, kondensatorer, spoler og zenerdioder. Almindeligvis produceres og vælges dimensioner af andre typer af elektriske komponenter fra Renard-talserien i stedet (for eksempel sikringer) eller er definerede efter relevante produkt standarder (for eksempel ledninger).
IEC 60063 tallene er som følger. E6-talserien er hvert andet element af E12-talserien, som igen er hvert andet element af E24-talserien:
E6 ( 20%): 10 15 22 33 47 68
E12 ( 10%): 10 12 15 18 22 27 33 39 47 56 68 82
E24 ( 5%): 10 12 15 18 22 27 33 39 47 56 68 82
11 13 16 20 24 30 36 43 51 62 75 91
I E48-talserien anvendes 3 betydende cifre og værdierne justeres lidt. Igen er E48-talserien hvert andet element af E96-talserien, som igen er hvert andet element af E192-talserien:
E48 ( 2%): 100 121 147 178 215 261 316 383 464 562 681 825
105 127 154 187 226 274 332 402 487 590 715 866
110 133 162 196 237 287 348 422 511 619 750 909
115 140 169 205 249 301 365 442 536 649 787 953
E96 ( 1%): 100 121 147 178 215 261 316 383 464 562 681 825
102 124 150 182 221 267 324 392 475 576 698 845
105 127 154 187 226 274 332 402 487 590 715 866
107 130 158 191 232 280 340 412 499 604 732 887
110 133 162 196 237 287 348 422 511 619 750 909
113 137 165 200 243 294 357 432 523 634 768 931
115 140 169 205 249 301 365 442 536 649 787 953
118 143 174 210 255 309 374 453 549 665 806 976
E192 (0.5%) 100 121 147 178 215 261 316 383 464 562 681 825
101 123 149 180 218 264 320 388 470 569 690 835
102 124 150 182 221 267 324 392 475 576 698 845
104 126 152 184 223 271 328 397 481 583 706 856
105 127 154 187 226 274 332 402 487 590 715 866
106 129 156 189 229 277 336 407 493 597 723 876
107 130 158 191 232 280 340 412 499 604 732 887
109 132 160 193 234 284 344 417 505 612 741 898
110 133 162 196 237 287 348 422 511 619 750 909
111 135 164 198 240 291 352 427 517 626 759 920
113 137 165 200 243 294 357 432 523 634 768 931
114 138 167 203 246 298 361 437 530 642 777 942
115 140 169 205 249 301 365 442 536 649 787 953
117 142 172 208 252 305 370 448 542 657 796 965
118 143 174 210 255 309 374 453 549 665 806 976
120 145 176 213 258 312 379 459 556 673 816 988
E192-talserien anvendes også til resistorer med tolerancer på 0,25% og 0,1%.
1% resistorer er tilgængelige i både E24-værdier og E96-værdier.
Kilder/referencer
ISO 3, Preferred numbers — Series of preferred numbers. International Organization for Standardization, 1973.
ISO 17, Guide to the use of preferred numbers and of series of preferred numbers. 1973.
ISO 497, Guide to the choice of series of preferred numbers and of series containing more rounded values of preferred numbers. 1973.
ISO 2848, Building construction — Modular coordination — Principles and rules. 1984.
ISO/TR 8389, Building construction — Modular coordination — System of preferred numbers defining multimodular sizes. International Organization for Standardization, 1984.
IEC 60063, Preferred number series for resistors and capacitors. International Electrotechnical Commission, 1963
BS 2045, Preferred numbers. British Standards Institute, 1965.
BS 2488, Schedule of preferred numbers for the resistance of resistors and the capacitance of capacitors for telecommunication equipment. 1966.
Se også
Liste over ISO-standarder
Eksterne henvisninger
Tal
Standarder
ISO-standarder | danish | 0.966594 |
Pony/src-collections-set-.txt |
set.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315type Set[A: (Hashable #read & Equatable[A] #read)] is HashSet[A, HashEq[A]]
type SetIs[A] is HashSet[A, HashIs[A!]]
class HashSet[A, H: HashFunction[A!] val] is Comparable[HashSet[A, H] box]
"""
A set, built on top of a HashMap. This is implemented as map of an alias of
a type to itself
"""
embed _map: HashMap[A!, A, H]
new create(prealloc: USize = 8) =>
"""
Defaults to a prealloc of 8.
"""
_map = _map.create(prealloc)
fun size(): USize =>
"""
The number of items in the set.
"""
_map.size()
fun space(): USize =>
"""
The available space in the set.
"""
_map.space()
fun apply(value: box->A!): this->A ? =>
"""
Return the value if its in the set, otherwise raise an error.
"""
_map(value)?
fun contains(value: box->A!): Bool =>
"""
Checks whether the set contains the value.
"""
_map.contains(value)
fun ref clear() =>
"""
Remove all elements from the set.
"""
_map.clear()
fun ref set(value: A) =>
"""
Add a value to the set.
"""
_map(value) = consume value
fun ref unset(value: box->A!) =>
"""
Remove a value from the set.
"""
try _map.remove(value)? end
fun ref extract(value: box->A!): A^ ? =>
"""
Remove a value from the set and return it. Raises an error if the value
wasn't in the set.
"""
_map.remove(value)?._2
fun ref union(that: Iterator[A^]) =>
"""
Add everything in that to the set.
"""
for value in that do
set(consume value)
end
fun ref intersect[K: HashFunction[box->A!] val = H](
that: HashSet[box->A!, K])
=>
"""
Remove everything that isn't in that.
"""
let start_size = _map.size()
var seen: USize = 0
var i: USize = -1
while seen < start_size do
try
i = next_index(i)?
if not that.contains(index(i)?) then
unset(index(i)?)
end
end
seen = seen + 1
end
fun ref difference(that: Iterator[A^]) =>
"""
Remove elements in this which are also in that. Add elements in that which
are not in this.
"""
for value in that do
try
extract(value)?
else
set(consume value)
end
end
fun ref remove(that: Iterator[box->A!]) =>
"""
Remove everything that is in that.
"""
for value in that do
unset(value)
end
fun add[K: HashFunction[this->A!] val = H](
value: this->A!)
: HashSet[this->A!, K]^
=>
"""
Add a value to the set.
"""
clone[K]() .> set(value)
fun sub[K: HashFunction[this->A!] val = H](
value: box->this->A!)
: HashSet[this->A!, K]^
=>
"""
Remove a value from the set.
"""
clone[K]() .> unset(value)
fun op_or[K: HashFunction[this->A!] val = H](
that: this->HashSet[A, H])
: HashSet[this->A!, K]^
=>
"""
Create a set with the elements of both this and that.
"""
let r = clone[K]()
for value in that.values() do
r.set(value)
end
r
fun op_and[K: HashFunction[this->A!] val = H](
that: this->HashSet[A, H])
: HashSet[this->A!, K]^
=>
"""
Create a set with the elements that are in both this and that.
"""
let r = HashSet[this->A!, K](size().min(that.size()))
for value in values() do
try
that(value)?
r.set(value)
end
end
r
fun op_xor[K: HashFunction[this->A!] val = H](
that: this->HashSet[A, H])
: HashSet[this->A!, K]^
=>
"""
Create a set with the elements that are in either set but not both.
"""
let r = HashSet[this->A!, K](size().max(that.size()))
for value in values() do
try
that(value)?
else
r.set(value)
end
end
for value in that.values() do
try
this(value)?
else
r.set(value)
end
end
r
fun without[K: HashFunction[this->A!] val = H](
that: this->HashSet[A, H])
: HashSet[this->A!, K]^
=>
"""
Create a set with the elements of this that are not in that.
"""
let r = HashSet[this->A!, K](size())
for value in values() do
try
that(value)?
else
r.set(value)
end
end
r
fun clone[K: HashFunction[this->A!] val = H](): HashSet[this->A!, K]^ =>
"""
Create a clone. The element type may be different due to aliasing and
viewpoint adaptation.
"""
let r = HashSet[this->A!, K](size())
for value in values() do
r.set(value)
end
r
fun eq(that: HashSet[A, H] box): Bool =>
"""
Returns true if the sets contain the same elements.
"""
(size() == that.size()) and (this <= that)
fun ne(that: HashSet[A, H] box): Bool =>
"""
Returns false if the sets contain the same elements.
"""
not (this == that)
fun lt(that: HashSet[A, H] box): Bool =>
"""
Returns true if every element in this is also in that, and this has fewer
elements than that.
"""
(size() < that.size()) and (this <= that)
fun le(that: HashSet[A, H] box): Bool =>
"""
Returns true if every element in this is also in that.
"""
try
for value in values() do
that(value)?
end
true
else
false
end
fun gt(that: HashSet[A, H] box): Bool =>
"""
Returns true if every element in that is also in this, and this has more
elements than that.
"""
(size() > that.size()) and (that <= this)
fun ge(that: HashSet[A, H] box): Bool =>
"""
Returns true if every element in that is also in this.
"""
that <= this
fun next_index(prev: USize = -1): USize ? =>
"""
Given an index, return the next index that has a populated value. Raise an
error if there is no next populated index.
"""
_map.next_index(prev)?
fun index(i: USize): this->A ? =>
"""
Returns the value at a given index. Raise an error if the index is not
populated.
"""
_map.index(i)?._2
fun values(): SetValues[A, H, this->HashSet[A, H]]^ =>
"""
Return an iterator over the values.
"""
SetValues[A, H, this->HashSet[A, H]](this)
class SetValues[A, H: HashFunction[A!] val, S: HashSet[A, H] #read] is
Iterator[S->A]
"""
An iterator over the values in a set.
"""
let _set: S
var _i: USize = -1
var _count: USize = 0
new create(set: S) =>
"""
Creates an iterator for the given set.
"""
_set = set
fun has_next(): Bool =>
"""
True if it believes there are remaining entries. May not be right if values
were added or removed from the set.
"""
_count < _set.size()
fun ref next(): S->A ? =>
"""
Returns the next value, or raises an error if there isn't one. If values
are added during iteration, this may not return all values.
"""
_i = _set.next_index(_i)?
_count = _count + 1
_set.index(_i)?
| pony | 1901014 | https://sv.wikipedia.org/wiki/Acanthogyrus%20holospinus | Acanthogyrus holospinus | Acanthogyrus holospinus är en hakmaskart som först beskrevs av Nibedita Sen 1937. Acanthogyrus holospinus ingår i släktet Acanthogyrus och familjen Quadrigyridae. Inga underarter finns listade i Catalogue of Life.
Källor
Hakmaskar
holospinus | swedish | 1.283339 |
Pony/collections-persistent-MapValues-.txt |
MapValues[K: Any #share, V: Any #share, H: HashFunction[K] val]¶
[Source]
class ref MapValues[K: Any #share, V: Any #share, H: HashFunction[K] val]
Constructors¶
create¶
[Source]
new ref create(
m: HashMap[K, V, H] val)
: MapValues[K, V, H] ref^
Parameters¶
m: HashMap[K, V, H] val
Returns¶
MapValues[K, V, H] ref^
Public Functions¶
has_next¶
[Source]
fun box has_next()
: Bool val
Returns¶
Bool val
next¶
[Source]
fun ref next()
: val->V ?
Returns¶
val->V ?
| pony | 1428850 | https://sv.wikipedia.org/wiki/Haskell | Haskell | Haskell kan syfta på:
Haskell (programspråk) – ett rent funktionellt programspråk
Personer
Arnold Haskell (1903–1980), brittisk danskritiker
Charles N. Haskell (1860–1933), amerikansk politiker
Floyd K. Haskell (1916–1998), amerikansk politiker
Antarktis
Mount Haskell,
USA
Haskell, Arkansas, ort, Saline County,
Haskell, Oklahoma, ort, Muskogee County,
Haskell, Texas, countyhuvudort, Haskell County,
Se även
Haskell County – flera
Robotskapade Antarktisförgreningar
Robotskapade USAförgreningar | swedish | 1.263307 |
Pony/src-ini-ini_map-.txt |
ini_map.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42use "collections"
type IniMap is Map[String, Map[String, String]]
primitive IniParse
"""
This is used to parse INI formatted text as a nested map of strings.
"""
fun apply(lines: Iterator[String]): IniMap ref^ ? =>
"""
This accepts a string iterator and returns a nested map of strings. If
parsing fails, an error is raised.
"""
let map = IniMap
let f = object
let map: IniMap = map
fun ref apply(section: String, key: String, value: String): Bool =>
try
if not map.contains(section) then
map.insert(section, Map[String, String])
end
map(section)?(key) = value
end
true
fun ref add_section(section: String): Bool =>
if not map.contains(section) then
map.insert(section, Map[String, String])
end
true
fun ref errors(line: USize, err: IniError): Bool =>
false
end
if not Ini(lines, f) then
error
end
map
| pony | 2528634 | https://sv.wikipedia.org/wiki/Stomatothrips%20crawfordi | Stomatothrips crawfordi | Stomatothrips crawfordi är en insektsart som beskrevs av Stannard 1968. Stomatothrips crawfordi ingår i släktet Stomatothrips och familjen rovtripsar. Inga underarter finns listade i Catalogue of Life.
Källor
Rovtripsar
crawfordi | swedish | 1.406144 |
Pony/format-FormatDefault-.txt |
FormatDefault¶
[Source]
primitive val FormatDefault is
FormatSpec val
Implements¶
FormatSpec val
Constructors¶
create¶
[Source]
new val create()
: FormatDefault val^
Returns¶
FormatDefault val^
Public Functions¶
eq¶
[Source]
fun box eq(
that: FormatDefault val)
: Bool val
Parameters¶
that: FormatDefault val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FormatDefault val)
: Bool val
Parameters¶
that: FormatDefault val
Returns¶
Bool val
| pony | 1947072 | https://sv.wikipedia.org/wiki/Daphnella%20lymneiformis | Daphnella lymneiformis | Daphnella lymneiformis är en snäckart som först beskrevs av Kiener 1840. Daphnella lymneiformis ingår i släktet Daphnella och familjen kägelsnäckor. Inga underarter finns listade i Catalogue of Life.
Källor
Kägelsnäckor
lymneiformis | swedish | 1.208717 |
Pony/process-KillError-.txt |
KillError¶
[Source]
primitive val KillError
Constructors¶
create¶
[Source]
new val create()
: KillError val^
Returns¶
KillError val^
Public Functions¶
string¶
[Source]
fun box string()
: String iso^
Returns¶
String iso^
eq¶
[Source]
fun box eq(
that: KillError val)
: Bool val
Parameters¶
that: KillError val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: KillError val)
: Bool val
Parameters¶
that: KillError val
Returns¶
Bool val
| pony | 743168 | https://sv.wikipedia.org/wiki/Vympel%20R-77 | Vympel R-77 | R-77 (NATO-beteckning AA-12 Adder) är en rysk jaktrobot som började utvecklas 1982 och togs i bruk i slutet av 80-talet. Den observerades först av väst 1992.
Varianter
R-77 (RVV-AE) – Ursprunglig version.
R-77PD (RVV-AE-PD) – Version med ramjetmotor och dubblerad räckvidd. (PD = Povysjenoj Dalnosti, ”ökad räckvidd”)
R-77M – Moderniserad version med laserzonrör.
R-77ME – Version med ramjetmotor och laserzonrör. (Energetitjeskaja)
Källor
Se även
AIM-120 AMRAAM
MBDA Meteor
Jaktrobotar | swedish | 1.051541 |
Pony/pony_bench--index-.txt |
Package
PonyBench provides a microbenchmarking framework. It is designed to measure
the runtime of synchronous and asynchronous operations.
Example Program¶
The following is a complete program with multiple trivial benchmarks followed
by their output.
use "time"
use "pony_bench"
actor Main is BenchmarkList
new create(env: Env) =>
PonyBench(env, this)
fun tag benchmarks(bench: PonyBench) =>
bench(_Nothing)
bench(_Fib(5))
bench(_Fib(10))
bench(_Fib(20))
bench(_Timer(10_000))
class iso _Nothing is MicroBenchmark
// Benchmark absolutely nothing.
fun name(): String => "Nothing"
fun apply() =>
// prevent compiler from optimizing out this operation
DoNotOptimise[None](None)
DoNotOptimise.observe()
class iso _Fib is MicroBenchmark
// Benchmark non-tail-recursive fibonacci
let _n: U64
new iso create(n: U64) =>
_n = n
fun name(): String =>
"_Fib(" + _n.string() + ")"
fun apply() =>
DoNotOptimise[U64](_fib(_n))
DoNotOptimise.observe()
fun _fib(n: U64): U64 =>
if n < 2 then 1
else _fib(n - 1) + _fib(n - 2)
end
class iso _Timer is AsyncMicroBenchmark
// Asynchronous benchmark of timer.
let _ts: Timers = Timers
let _ns: U64
new iso create(ns: U64) =>
_ns = ns
fun name(): String =>
"_Timer (" + _ns.string() + " ns)"
fun apply(c: AsyncBenchContinue) =>
_ts(Timer(
object iso is TimerNotify
fun apply(timer: Timer, count: U64 = 0): Bool =>
// signal completion of async benchmark iteration when timer fires
c.complete()
false
end,
_ns))
By default, the results are printed to stdout like so:
Benchmark results will have their mean and median adjusted for overhead.
You may disable this with --noadjust.
Benchmark mean median deviation iterations
Nothing 1 ns 1 ns ±0.87% 3000000
_Fib(5) 12 ns 12 ns ±1.02% 2000000
_Fib(10) 185 ns 184 ns ±1.03% 1000000
_Fib(20) 23943 ns 23898 ns ±1.11% 10000
_Timer (10000ns) 10360 ns 10238 ns ±3.25% 10000
The --noadjust option outputs results of the overhead measured prior to each
benchmark run followed by the unadjusted benchmark result. An example of the
output of this program with --noadjust is as follows:
Benchmark mean median deviation iterations
Benchmark Overhead 604 ns 603 ns ±0.58% 300000
Nothing 553 ns 553 ns ±0.30% 300000
Benchmark Overhead 555 ns 555 ns ±0.51% 300000
_Fib(5) 574 ns 574 ns ±0.43% 300000
Benchmark Overhead 554 ns 556 ns ±0.48% 300000
_Fib(10) 822 ns 821 ns ±0.39% 200000
Benchmark Overhead 554 ns 553 ns ±0.65% 300000
_Fib(20) 30470 ns 30304 ns ±1.55% 5000
Benchmark Overhead 552 ns 552 ns ±0.39% 300000
_Timer (10000 ns) 10780 ns 10800 ns ±3.60% 10000
It is recommended that a PonyBench program is compiled with the --runtimebc
option, if possible, and run with the --ponynoyield option.
Public Types¶
class AsyncBenchContinue
trait AsyncMicroBenchmark
class AsyncOverheadBenchmark
class BenchConfig
type Benchmark
interface BenchmarkList
trait MicroBenchmark
class OverheadBenchmark
actor PonyBench
| pony | 632112 | https://da.wikipedia.org/wiki/Foretrukne%20tal | Foretrukne tal | Foretrukne tal (også kaldet foretrukne værdier) er standardanbefalinger til at vælge eksakte produktdimensioner med ens begrænsninger. I industridesign kan produktudviklere vælge mange forskellige længder, diametre, rumfang og andre karakteristiske kvantiteter. Selv om alle disse valg er begrænset af funktionalitet, brugervenlighed, kompatibilitet, sikkerhed eller omkostninger, er det sædvanligvis et stort spillerum for valg af eksakte dimensionsvalg.
Foretrukne tal tjener to hensigter:
Brug af foretrukne tal øger sandsynligheden for at andre designere vil gøre de samme valg. Dette er specielt nyttigt, hvor de valgte dimensioner påvirker kompatibilitet. Hvis for eksempel inderdiameteren til gryder eller afstanden mellem skruer i væggen er valgt fra en serie med foretrukne nummer, vil sandsynligheden for at gamle gryder og vægg-plugg-huller kan blive genbrugt, når det oprindelige produkt udskiftes.
Foretrukne tal vælges sådan at et produkt produceres i mange forskellige størrelser, så vil disse ende op som ens på en logaritmisk skala. Det vil derfor hjælpe til at minimere antallet af forskellige størrelser som må produceres og lagres.
Renard-tal
Den franske hæringeniøren Charles Renard foreslog i 1870'erne en mængde med foretrukne tal anvendt sammen med det metriske system.
Hans system blev tilpasset i 1952 som den internationale standard ISO 3. Renard's system af foretrukne tal inddeler intervallet fra 1 til 10 ind i 5, 10, 20 eller 40 trin. Faktoren mellem to fortløbende tal i en Renard-talserie (Bedre?: Renard-række) er konstant (før afrunding), nemlig den 5., 10., 20. eller 40. rod af 10 (hhv. ca. 1,58, 1,26, 1,12 og 1.06), hvilket leder til en geometrisk række. På denne måde minimeres den maksimale relative fejl hvis et vilkårligt tal erstattes af det nærmeste Renard-tal multipliceret med den passende potens af 10.
Disse tal kan afrundes til enhver vilkårlig præcision, da de er irrationelle. R5 afrundet til forskellige præcisioner:
Ettere: 1 2 3 4 6
Tiere: 1,0 1,6 2,5 4,0 6,3
Hundreder: 1,00 1,58 2,51 3,98 6,31
Eksempel: Hvis vores designrestriktioner fortæller os at de to skruer i vores gadget skal placeres mellem 32 mm og 55 mm fra hinanden, kan vi vælge at den skal være 40 mm, fordi 4 er i R5-talserien af foretrukne tal.
Eksempel: Hvis du ønsker at producere en mængde søm med længder mellem ca. 15 og 300 mm, så vil anvendelsen af R5-talserien lede til et produkt repertoire af disse sømlængder: 16 mm, 25 mm, 40 mm, 63 mm, 100 mm, 160 mm og 250 mm.
Hvis en finere opløsning er behøvet, kan yderligere fem tal tilføjes til serien, en efter hver af de originale R5-tal – og vi ender med R10-talserien:
R10: 1,00 1,25 1,60 2,00 2,50 3,15 4,00 5,00 6,30 8,00
Når en endnu finere graduering er behøvet, kan R20-, R40- og R80-talserierne anvendes:
R20: 1,00 1,25 1,60 2,00 2,50 3,15 4,00 5,00 6,30 8,00
1,12 1,40 1,80 2,24 2,80 3,55 4,50 5,60 7,10 9,00
R40: 1,00 1,25 1,60 2,00 2,50 3,15 4,00 5,00 6,30 8,00
1,06 1,32 1,70 2,12 2,65 3,35 4,25 5,30 6,70 8,50
1,12 1,40 1,80 2,24 2,80 3,55 4,50 5,60 7,10 9,00
1,18 1,50 1,90 2,36 3,00 3,75 4,75 6,00 7,50 9,50
R80: 1,00 1,25 1,60 2,00 2,50 3,15 4,00 5,00 6,30 8,00
1,03 1,28 1,65 2,06 2,58 3,25 4,12 5,15 6,50 8,25
1,06 1,32 1,70 2,12 2,65 3,35 4,25 5,30 6,70 8,50
1,09 1,36 1,75 2,18 2,72 3,45 4,37 5,45 6,90 8,75
1,12 1,40 1,80 2,24 2,80 3,55 4,50 5,60 7,10 9,00
1,15 1,45 1,85 2,30 2,90 3,65 4,62 5,80 7,30 9,25
1,18 1,50 1,90 2,36 3,00 3,75 4,75 6,00 7,50 9,50
1,22 1,55 1,95 2,43 3,07 3,87 4,87 6,15 7,75 9,75
I nogle anvendelser er mere afrundede værdier ønskelige, enten fordi tallene fra den normale serie vill underforstå en urealistisk høj nøjagtighed – eller fordi en heltalsværdi er ønskelig (f.eks., antallet af tænder på et tandhjul). For at opfylde disse behov er en mere afrundet version af Renard-talserien defineret i ISO 3:
R5″: 1 1,5 2,5 4 6
R10′: 1 1,25 1,6 2 2,5 3,2 4 5 6,3 8
R10″: 1 1,2 1,5 2 2,5 3 4 5 6 8
R20′: 1 1,25 1,6 2 2,5 3,2 4 5 6,3 8
1,1 1,4 1,8 2,2 2,8 3,6 4,5 5,6 7,1 9
R20″: 1 1,2 1,5 2 2,5 3 4 5 6 8
1,1 1,4 1,8 2,2 2,8 3,5 4,5 5,5 7 9
R40′: 1 1,25 1,6 2 2,5 3,2 4 5 6,3 8
1,05 1,3 1,7 2,1 2,6 3,4 4,2 5,3 6,7 8,5
1,1 1,4 1,8 2,2 2,8 3,6 4,5 5,6 7,1 9
1,2 1,5 1,9 2,4 3 3,8 4,8 6 7,5 9,5
Da Renard-tallene gentages efter hver 10-foldig ændring af skalaen, er de især egnet til at blive anvendt med SI-enheder. Det gør ingen forskel om Renard-tallene anvendes med meter eller kilometer.
Renard-tallene er afrundede resultater af formlen:
,
hvor b er den valgte talserie antal (for eksempel b = 40 for R40-talserien), og i er talseriens ite element (hvor i = 0 løber til i = b).
Detaljistforpakning
I nogle lande begrænser forbruger-lovgivningen antallet af forskellige forbrugerpakninger(f-pak) et givet produkt kan sælges i, for at det skal være lettere for forbrugeren at sammenligne priser.
Et eksempel på en sådan regulering er EU-direktivet, som behandler væsker (75/106/EEC). Direktivet begrænser antallet af forskellige vinflaskestørrelser til 0,1, 0,25 (2/8), 0,375 (3/8), 0,5 (4/8), 0,75 (6/8), 1, 1,5, 2, 3, and 5 liter. Tilsvarende lister findes for mange andre typer produkt.
E-serien
Indenfor elektronik definerer den internationale standard IEC 60063 en anden foretrukken talserie for resistorer, kondensatorer, spoler og zenerdioder. (historisk er den fra engelsk RMA Preferred Number Values of Fixed Composition Resistors) Talserien fungerer omtrent ligesom Renard-talserierne, undtagen at den underinddeler intervallet fra 1 til 10 ind i 6, 12, 24, osv. trin. Disse underinddelinger sikrer at når en vilkårlig værdi erstattes med den nærmeste fortrukne talværdi, er den maksimale relative fejl i omegnen af hhv. 20%, 10%, 5%, osv.
Anvendelse af E-talserierne er normalt afgrænset til resistorer, kondensatorer, spoler og zenerdioder. Almindeligvis produceres og vælges dimensioner af andre typer af elektriske komponenter fra Renard-talserien i stedet (for eksempel sikringer) eller er definerede efter relevante produkt standarder (for eksempel ledninger).
IEC 60063 tallene er som følger. E6-talserien er hvert andet element af E12-talserien, som igen er hvert andet element af E24-talserien:
E6 ( 20%): 10 15 22 33 47 68
E12 ( 10%): 10 12 15 18 22 27 33 39 47 56 68 82
E24 ( 5%): 10 12 15 18 22 27 33 39 47 56 68 82
11 13 16 20 24 30 36 43 51 62 75 91
I E48-talserien anvendes 3 betydende cifre og værdierne justeres lidt. Igen er E48-talserien hvert andet element af E96-talserien, som igen er hvert andet element af E192-talserien:
E48 ( 2%): 100 121 147 178 215 261 316 383 464 562 681 825
105 127 154 187 226 274 332 402 487 590 715 866
110 133 162 196 237 287 348 422 511 619 750 909
115 140 169 205 249 301 365 442 536 649 787 953
E96 ( 1%): 100 121 147 178 215 261 316 383 464 562 681 825
102 124 150 182 221 267 324 392 475 576 698 845
105 127 154 187 226 274 332 402 487 590 715 866
107 130 158 191 232 280 340 412 499 604 732 887
110 133 162 196 237 287 348 422 511 619 750 909
113 137 165 200 243 294 357 432 523 634 768 931
115 140 169 205 249 301 365 442 536 649 787 953
118 143 174 210 255 309 374 453 549 665 806 976
E192 (0.5%) 100 121 147 178 215 261 316 383 464 562 681 825
101 123 149 180 218 264 320 388 470 569 690 835
102 124 150 182 221 267 324 392 475 576 698 845
104 126 152 184 223 271 328 397 481 583 706 856
105 127 154 187 226 274 332 402 487 590 715 866
106 129 156 189 229 277 336 407 493 597 723 876
107 130 158 191 232 280 340 412 499 604 732 887
109 132 160 193 234 284 344 417 505 612 741 898
110 133 162 196 237 287 348 422 511 619 750 909
111 135 164 198 240 291 352 427 517 626 759 920
113 137 165 200 243 294 357 432 523 634 768 931
114 138 167 203 246 298 361 437 530 642 777 942
115 140 169 205 249 301 365 442 536 649 787 953
117 142 172 208 252 305 370 448 542 657 796 965
118 143 174 210 255 309 374 453 549 665 806 976
120 145 176 213 258 312 379 459 556 673 816 988
E192-talserien anvendes også til resistorer med tolerancer på 0,25% og 0,1%.
1% resistorer er tilgængelige i både E24-værdier og E96-værdier.
Kilder/referencer
ISO 3, Preferred numbers — Series of preferred numbers. International Organization for Standardization, 1973.
ISO 17, Guide to the use of preferred numbers and of series of preferred numbers. 1973.
ISO 497, Guide to the choice of series of preferred numbers and of series containing more rounded values of preferred numbers. 1973.
ISO 2848, Building construction — Modular coordination — Principles and rules. 1984.
ISO/TR 8389, Building construction — Modular coordination — System of preferred numbers defining multimodular sizes. International Organization for Standardization, 1984.
IEC 60063, Preferred number series for resistors and capacitors. International Electrotechnical Commission, 1963
BS 2045, Preferred numbers. British Standards Institute, 1965.
BS 2488, Schedule of preferred numbers for the resistance of resistors and the capacitance of capacitors for telecommunication equipment. 1966.
Se også
Liste over ISO-standarder
Eksterne henvisninger
Tal
Standarder
ISO-standarder | danish | 0.966594 |
Pony/pony_check-IntProperty-.txt |
IntProperty¶
[Source]
A property implementation for conveniently evaluating properties
for all Pony Integer types at once.
The property needs to be formulated inside the method int_property:
class DivisionByZeroProperty is IntProperty
fun name(): String => "div/0"
fun int_property[T: (Int & Integer[T] val)](x: T, h: PropertyHelper)? =>
h.assert_eq[T](T.from[U8](0), x / T.from[U8](0))
trait ref IntProperty is
Property1[IntPropertySample ref] ref
Implements¶
Property1[IntPropertySample ref] ref
Public Functions¶
gen¶
[Source]
fun box gen()
: Generator[IntPropertySample ref] box
Returns¶
Generator[IntPropertySample ref] box
property¶
[Source]
fun ref property(
sample: IntPropertySample ref,
h: PropertyHelper val)
: None val ?
Parameters¶
sample: IntPropertySample ref
h: PropertyHelper val
Returns¶
None val ?
int_property[T: ((I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Integer[T] val)]¶
[Source]
fun ref int_property[T: ((I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val) & Integer[T] val)](
x: T,
h: PropertyHelper val)
: None val ?
Parameters¶
x: T
h: PropertyHelper val
Returns¶
None val ?
name¶
fun box name()
: String val
Returns¶
String val
params¶
fun box params()
: PropertyParams val
Returns¶
PropertyParams val
| pony | 409599 | https://nn.wikipedia.org/wiki/UN-nummer | UN-nummer | UN-nummer (forkorta frå engelsk: United Nations number) er eit fire siffera nummer som identifiserer farlege materiale og gjenstandar (som sprengstoff, brennbar væske, oksidiserande, giftig væske, osfr.) i samband med internasjonal handel og transport. Somme farlege stoff har sine eige UN-nummer (til dømes akrylamid har UN 2074), medan nokre kjemikalar eller produkt med liknande eigenskapar har eit felles UN-nummer. Ein kjemikalie i fast tilstand kan ha eit anna UN-nummer enn kjemikalien i flytande form dersom eigenskapane er ymse; same stoff med ulik konsentrasjon kan òg ha ulike UN-nummer.
Regulering
Det finst ulike internasjonale regelverk og internasjonale institusjonar som tek føre seg ulike typar transportmiddel:
RID for jarnbanetrafikk
ADR-S for landtransport
ICAO-TI for luftfart
IMDG for sjøfart
Tildeling av UN-nummer
UN-nummer varierer frå UN 0004 til omtrent UN 3550 (UN 0001–UN 0003 er ikkje lenger i bruk) og er tildelt av FNs ekspertkomité for transport av farleg gods. Dei vert publisert som ein del av sine tilrådingar om transport av farleg gods, òg kjent som Orange Book. Det finst ikkje UN-nummer for ikkje-farlege stoff.
Døme på UN-nummer
Ammoniakk: 1005
Bensin: 1203
Diesel: 1202
Etanol: 1170
Klor: 1017
Metanol: 1230
Merking av transportmiddel
Landtransport
Varebilar, lastebilar og jarnbanevogner som fraktar farleg gods vert merka med oransje rektangulære skilt, ADR-skilt. Farenummer er skrive i øvre del, medan UN-nummeret i nedre del av skiltet. Dei ulike farenummera tyder:
0 – Inga betyding / Ingen sekundærfare
2 – Gass
3 – Brannfarleg væske eller gass
4 – Brannfarleg fast stoff
5 – Oksiderande
6 – Giftig
7 – Radioaktiv
8 – Etsande
9 – Risiko for ofseleg reaksjon
x – Farleg reaksjon med vatn
Døme på kombinerte farenummer:
20 – Kvelande gass eller gass utan tilleggsrisiko
22 – Nedkjølt flytande gass, kvelande
23 – Brennbar gass
268 – Giftig gass, etsande
30 – Brannfarleg væske
336 – særleg brannfarleg væske, giftig
80 – Etsande eller veikt etsande stoff
Når to like farenummer er skrive etter kvarandre viser det til ein forsterka fare. Til dømes tyder 33 at noko er ekstra brannfarleg, og 88 for særleg etsande stoff.
Andre identifiseringsnummer
Eit NA-nummer (North America number) vert tildelt av det amerikanske transportdepartementet og er identisk med UN-nummer med somme unntak. Til dømes, NA 3334, er sjølvforsvarspray, medan UN 3334 er væske som er regulert til luftfart. Visse stoff som ikkje har eit UN-nummer kan likevel ha eit NA-nummer. Desse unntaka der det ikkje finst eit UN-nummer nyttar området NA 9000–NA 9279.
Eit ID-nummer er ein tredje type identifikasjonsnummer som vert nytta for farlege stoff som vert vigt til lufttransport. Stoff med ID-nummer er knytt til egna fraktnamn som er godkjend av ICAO Technical Instructions. ID 8000, Forbrukarvare har ikkje eit UN- eller NA-nummer og er klassifisert som eit farleg materiale i klasse 9.
Sjå òg
Globalt Harmonisert System for klassifisering og merking av kjemikaliar
Farleg gods
CAS-nummer
Kjelder
Denne artikkelen bygger på «UN number» frå , den 31. juli 2023.
Bakgrunnsstoff
Regelverk
«Dangerous Goods» i United Nations Economic Commission for Europe (UNECE).
«UN Recommendations on the Transport of Dangerous Goods». Del 2 definerer fareklasser og del 3 inneheld ein fullstendig liste over alle UN-nummer og fareidentifikatorar.
Merking av køyretøy
«Hazard Identification Number Placard i International Labour Organization.
«Farlig gods» i brannteori.no
«Informasjon om farlig gods: Merking» ved direktoratet for samfunnssikkerhet og beredskap.
Liste over alle NA-nummer saman med tryggingsprosedyrar. The Emergency Response Guidebook frå U.S. Department of Transportation.
NA- og UN-nummer databasesøk
Farlig gods-permen UN-nummersøk og andre verktøy i dsb.no
Cameo Chemicals både NA- og UN-nummersøk.
Kjemisk nummerering | norwegian_nynorsk | 1.335855 |
Pony/pony_bench-BenchConfig-.txt |
BenchConfig¶
[Source]
Configuration of a benchmark.
class val BenchConfig
Constructors¶
create¶
[Source]
new val create(
samples': USize val = 20,
max_iterations': U64 val = 1000000000,
max_sample_time': U64 val = 100000000)
: BenchConfig val^
Parameters¶
samples': USize val = 20
max_iterations': U64 val = 1000000000
max_sample_time': U64 val = 100000000
Returns¶
BenchConfig val^
Public fields¶
let samples: USize val¶
[Source]
Total number of samples to be measured. (Default: 20)
let max_iterations: U64 val¶
[Source]
Maximum number of iterations to execute per sample. (Default: 1_000_000_000)
let max_sample_time: U64 val¶
[Source]
Maximum time to execute a sample in Nanoseconds. (Default: 100_000_000)
| pony | 14328 | https://da.wikipedia.org/wiki/Tal | Tal | Tal er et abstrakt begreb, der bruges til at angive mængde.
I matematikken findes der mange forskellige tal, for eksempel de naturlige tal, heltal, brøker, rationale tal, irrationale tal, reelle tal, imaginære tal og komplekse tal.
De naturlige tal ℕ (N) som 1, 2, 3, 4... osv. er fundamentale for al matematik; De betegnes
eller – hvis man vil præcisere, at tallet 0 medregnes – .
Udvider vi de naturlige tal (inkl. 0) med de negative, hele tal, får vi de hele tal ℤ (Z).
Dette kan igen udvides med de positive og negative brøker til det rationale tallegeme ℚ (Q). Den del af de rationale tal, som kan repræsenteres ved en endelig decimaludvikling, kaldes de decimale tal og benævnes D.
Ved yderligere udvidelse af tallegemet opstår de reelle tal ℝ (R), hvoriblandt findes de irrationale tal som er de reelle tal, der ikke tilhører det rationale tallegeme.
Udvides det reelle tallegeme yderligere med rødderne til de generelle polynomier med komplekse koefficienter, fås det komplekse tallegeme ℂ (C).
Dette kan udtrykkes i den særlige skrifttype blackboard bold således:
Betydningen af begreberne tallegeme og tal kan fastlægges til følgende:
Man kalder en uendelig mængde af symboler for et tallegeme, og det enkelte symbol for et tal, hvis mængden opfylder følgende tre betingelser:
at de naturlige tal indgår i mængdens elementer
at der findes et størrelseskriterium, som kan afgøre om to elementer er lige store (eller hvilket der er størst).
at der for to vilkårlige elementer i mængden kan udvikles et skema for at lægge dem sammen og gange dem med hinanden, som har samme egenskaber som de tilsvarende operationer for de naturlige tal (og som reduceres til disse, når de to elementer er naturlige tal). De egenskaber, der her tænkes på, er de grundlæggende egenskaber at være kommutativ, associativ og distributiv.
Visse mængder af tal er bestemt ved særlige egenskaber, for eksempel primtal, kvadrattal, fuldkomne tal og Fibonaccis tal.
Visse tal har særlige egenskaber eller betydninger, som er beskrevet andetsteds i Wikipedia: Kategorien for artikler om bestemte tal indeholder en oversigt over disse artikler.
Her er en lille skala over tal:
0,000 000 000 000 000 000 000 001 = 10−24 = Kvadrilliontedel
0,000 000 000 000 000 000 001 = 10−21 = Trilliardtedel
0,000 000 000 000 000 001 = 10−18 = Trilliontedel
0,000 000 000 000 001 = 10−15 = Billiardtedel
0,000 000 000 001 = 10−12 = Billiontedel
0,000 000 001 = 10−9 = Millardtedel
0,000 001 = 10−6 = Milliontedel
0,001 = 10−3 = Tusindedel
0,01 = 10−2 = Hundrededel
0,1 = 10−1 = Tiendedel
1 = 100 = En
1 0 = 101 = Ti
1 00 = 10² = Hundrede
1 000 = 103 = Tusind
1 000 000 = 106 = Million
1 000 000 000 = 109 = Milliard
1 000 000 000 000 = 1012 = Billion
1 000 000 000 000 000 = 1015 = Billiard
1 000 000 000 000 000 000 = 1018 = Trillion
1 000 000 000 000 000 000 000 = 1021 = Trilliard
1 000 000 000 000 000 000 000 000 = 1024 = Kvadrillion
1 000 000 000 000 000 000 000 000 000 = 1027 = Kvadrilliard
1 000 000 000 000 000 000 000 000 000 000 = 1030 = Kvintillion
1 000 000 000 000 000 000 000 000 000 000 000 = 1033 = Kvintilliard
et et-tal med 100 nuller efter sig = 10100 = Googol
et et-tal med en googol nuller efter sig =10Googol = = Googolplex
Det kan bemærkes, at amerikansk og moderne britisk sprogbrug har en række falske venner blandt de store tal, idet fx "billion" på engelsk betegner 109, altså en dansk milliard, og ikke en dansk billion (1012); se Store tal.
Se også
Talord
Arabiske talsystem
Kinesiske tal
Romertal
Urnemarkskulturens talsystem
Foretrukne tal
Eksterne henvisninger
Takasugi Shinji: The Number System of Danish
Hovedadresse: Takasugi Shinji: Number Systems of the World
Numbers from 1 to 10 in Over 4000 Languages
Wiktionary article on number
What's special about this number?
Lykketal og uheldige tal Artikel på Dansk Folkemindesamlings site.
Matematiske objekter | danish | 0.878901 |
Pony/builtin-Number-.txt |
Number¶
[Source]
type Number is
(I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val | F32 val | F64 val)
Type Alias For¶
(I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val | F32 val | F64 val)
| pony | 4320573 | https://sv.wikipedia.org/wiki/Isachne%20vaughanii | Isachne vaughanii | Isachne vaughanii är en gräsart som beskrevs av Charles Edward Hubbard. Isachne vaughanii ingår i släktet Isachne och familjen gräs. Inga underarter finns listade i Catalogue of Life.
Källor
Gräs
vaughanii | swedish | 1.543164 |
Pony/builtin-InputNotify-.txt |
InputNotify¶
[Source]
Notification for data arriving via an input stream.
interface ref InputNotify
Public Functions¶
apply¶
[Source]
Called when data is available on the stream.
fun ref apply(
data: Array[U8 val] iso)
: None val
Parameters¶
data: Array[U8 val] iso
Returns¶
None val
dispose¶
[Source]
Called when no more data will arrive on the stream.
fun ref dispose()
: None val
Returns¶
None val
| pony | 2848062 | https://sv.wikipedia.org/wiki/Dovania%20neumanni | Dovania neumanni | Dovania neumanni är en fjärilsart som beskrevs av Jordan 1925. Dovania neumanni ingår i släktet Dovania och familjen svärmare. Inga underarter finns listade i Catalogue of Life.
Källor
Svärmare
neumanni | swedish | 1.451741 |
Pony/format-FormatBinaryBare-.txt |
FormatBinaryBare¶
[Source]
primitive val FormatBinaryBare is
FormatSpec val
Implements¶
FormatSpec val
Constructors¶
create¶
[Source]
new val create()
: FormatBinaryBare val^
Returns¶
FormatBinaryBare val^
Public Functions¶
eq¶
[Source]
fun box eq(
that: FormatBinaryBare val)
: Bool val
Parameters¶
that: FormatBinaryBare val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: FormatBinaryBare val)
: Bool val
Parameters¶
that: FormatBinaryBare val
Returns¶
Bool val
| pony | 828340 | https://da.wikipedia.org/wiki/Bofors | Bofors | AB Bofors var en svensk industrivirksomhed og våbenproducent med hovedkontor i Karlskoga i Värmland. Virksomheden blev etableret som et jernbrug i 1646 og blev en førende stålproducent i løbet af 1870'erne. Bofors begyndte at fremstile kanoner i 1883. Virksomheden havde Alfred Nobel som hovedejer i 1894–1896. I 1898 begyndte Bofors også at fremstille krudt og senere eksplosiver. Virksomheden fortsatte sin vækst i løbet af 1900-tallet, ikke mindst grundet omfattende våbenleverancer til det svenske forsvar under begge verdenskrige, men også som følge af eksport. Våbenproduktionen blev udvidet til også at omfatte missiler og kampvogne samt civile produkter som kemiske stoffer og lægemidler.
Bofors' virksomhed blev i 2000 opdelt mellem Saab Bofors Dynamics AB (missiler og panserværnsvåben), der er ejet af den svenske forsvarskoncern SAAB-gruppen, og BAE Systems Bofors AB (ildrørsystemer og mellemkaliber / tung ammunition), der indgår i den amerikanske forsvarskoncern BAE Systems Inc., der er en del af den britiske virksomhed BAE Systems Ltd.
Eksterne links
BAE Systems Plc
BAE Systems Bofors AB
Saab Bofors Dynamics AB
Etableret i 1646
Etableret i 1873
Ophørt i 2000
Forsvarsvirksomheder fra Sverige
Metalvirksomheder fra Sverige | danish | 1.169994 |
Pony/6_errors.txt | # Errors
Pony doesn't feature exceptions as you might be familiar with them from languages like Python, Java, C++ et al. It does, however, provide a simple partial function mechanism to aid in error handling. Partial functions and the `error` keyword used to raise them look similar to exceptions in other languages but have some important semantic differences. Let's take a look at how you work with Pony's error and then how it differs from the exceptions you might be used to.
## Raising and handling errors
An error is raised with the command `error`. At any point, the code may decide to declare an `error` has occurred. Code execution halts at that point, and the call chain is unwound until the nearest enclosing error handler is found. This is all checked at compile time so errors cannot cause the whole program to crash.
Error handlers are declared using the `try`-`else` syntax.
```pony
try
callA()
if not callB() then error end
callC()
else
callD()
end
```
In the above code `callA()` will always be executed and so will `callB()`. If the result of `callB()` is true then we will proceed to `callC()` in the normal fashion and `callD()` will not then be executed.
However, if `callB()` returns false, then an error will be raised. At this point, execution will stop and the nearest enclosing error handler will be found and executed. In this example that is, our else block and so `callD()` will be executed.
In either case, execution will then carry on with whatever code comes after the `try end`.
__Do I have to provide an error handler?__ No. The `try` block will handle any errors regardless. If you don't provide an error handler then no error handling action will be taken - execution will simply continue after the `try` expression.
If you want to do something that might raise an error, but you don't care if it does you can just put it in a `try` block without an `else`.
```pony
try
// Do something that may raise an error
end
```
__Is there anything my error handler has to do?__ No. If you provide an error handler then it must contain some code, but it is entirely up to you what it does.
__What's the resulting value of a try block?__ The result of a `try` block is the value of the last statement in the `try` block, or the value of the last statement in the `else` clause if an error was raised. If an error was raised and there was no `else` clause provided, the result value will be `None`.
## Partial functions
Pony does not require that all errors are handled immediately as in our previous examples. Instead, functions can raise errors that are handled by whatever code calls them. These are called partial functions (this is a mathematical term meaning a function that does not have a defined result for all possible inputs, i.e. arguments). Partial functions __must__ be marked as such in Pony with a `?`, both in the function signature (after the return type) and at the call site (after the closing parentheses).
For example, a somewhat contrived version of the factorial function that accepts a signed integer will error if given a negative input. It's only partially defined over its valid input type.
```pony
fun factorial(x: I32): I32 ? =>
if x < 0 then error end
if x == 0 then
1
else
x * factorial(x - 1)?
end
```
Everywhere that an error can be generated in Pony (an error command, a call to a partial function, or certain built-in language constructs) must appear within a `try` block or a function that is marked as partial. This is checked at compile time, ensuring that an error cannot escape handling and crash the program.
Prior to Pony 0.16.0, call sites of partial functions were not required to be marked with a `?`. This often led to confusion about the possibilities for control flow when reading code. Having every partial function call site clearly marked makes it very easy for the reader to immediately understand everywhere that a block of code may jump away to the nearest error handler, making the possible control flow paths more obvious and explicit.
## Partial constructors and behaviours
Class constructors may also be marked as partial. If a class constructor raises an error then the construction is considered to have failed and the object under construction is discarded without ever being returned to the caller.
When an actor constructor is called the actor is created and a reference to it is returned immediately. However, the constructor code is executed asynchronously at some later time. If an actor constructor were to raise an error it would already be too late to report this to the caller. For this reason, constructors for actors may not be partial.
Behaviours are also executed asynchronously and so cannot be partial for the same reason.
## Try-then blocks
In addition to an `else` error handler, a `try` command can have a `then` block. This is executed after the rest of the `try`, whether or not an error is raised or handled. Expanding our example from earlier:
```pony
try
callA()
if not callB() then error end
callC()
else
callD()
then
callE()
end
```
The `callE()` will always be executed. If `callB()` returns true then the sequence executed is `callA()`, `callB()`, `callC()`, `callE()`. If `callB()` returns false then the sequence executed is `callA()`, `callB()`, `callD()`, `callE()`.
__Do I have to have an else error handler to have a then block?__ No. You can have a `try`-`then` block without an `else` if you like.
__Will my then block really always be executed, even if I return inside the try?__ Yes, your `then` expression will __always__ be executed when the `try` block is complete. The only way it won't be is if the `try` never completes (due to an infinite loop), the machine is powered off, or the process is killed (and then, maybe).
## With blocks
A `with` expression can be used to ensure disposal of an object when it is no longer needed. A common case is a database connection which needs to be closed after use to avoid resource leaks on the server. For example:
```pony
with obj = SomeObjectThatNeedsDisposing() do
// use obj
end
```
`obj.dispose()` will be called whether the code inside the `with` block completes successfully or raises an error. To take part in a `with` expression, the object that needs resource clean-up must, therefore, provide a `dispose()` method:
```pony
class SomeObjectThatNeedsDisposing
// constructor, other functions
fun dispose() =>
// release resources
```
Multiple objects can be set up for disposal:
```pony
with obj = SomeObjectThatNeedsDisposing(), other = SomeOtherDisposableObject() do
// use obj
end
```
The value of a `with` expression is the value of the last expression in the block.
## Language constructs that can raise errors
The only language construct that can raise an error, other than the `error` command or calling a partial method, is the `as` command. This converts the given value to the specified type if it can be. If it can't then an error is raised. This means that the `as` command can only be used inside a try block or a partial method.
## Comparison to exceptions in other languages
Pony errors behave very much the same as those in C++, Java, C#, Python, and Ruby. The key difference is that Pony errors do not have a type or instance associated with them. This makes them the same as C++ exceptions would be if a fixed literal was always thrown, e.g. `throw 3;`. This difference simplifies error handling for the programmer and allows for much better runtime error handling performance.
The `else` handler in a `try` expression is just like a `catch(...)` in C++, `catch(Exception e)` in Java or C#, `except:` in Python, or `rescue` in Ruby. Since exceptions do not have types there is no need for handlers to specify types or to have multiple handlers in a single try block.
The `then` block in a `try` expression is just like a `finally` in Java, C#, or Python and `ensure` in Ruby.
If required, error handlers can "reraise" by using the `error` command within the handler.
| pony | 8534195 | https://sv.wikipedia.org/wiki/TypeScript | TypeScript | TypeScript är ett programmeringsspråk med öppen källkod som skapats den 1 oktober 2012 och upprätthålls av Microsoft. TypeScript bygger på JavaScript och lägger till flera avancerade funktioner som exempelvis statisk typkontroll, vilket innebär att typen (t.ex. heltal, sträng, objekt etc.) av variabler och parametrar definieras vid kompileringstiden i stället för vid körningstiden. På så sätt kan potentiella fel i koden identifieras och åtgärdas tidigt i utvecklingsprocessen, före programmet faktiskt körs. Det ökar säkerheten i koden och gör det enklare att hålla reda på och felsöka den. TypeScript tillämpar statisk typkontroll på detta sätt, medan JavaScript är ett dynamiskt typat språk.
Huvudsyftet med TypeScript är att förbättra utvecklarens produktivitet och säkerhet genom ett effektivare sätt att koda och enklare felsökning jämfört med vanlig Javascript, som inte har alla dessa funktioner.
TypeScript kompilerar sedan koden till Javascript i ett kortfattat och effektivt format, vilket innebär att koden kan köras på alla plattformar som stöder JavaScript.
En TypeScript-fil har vanligtvis filavslutningen .ts eller .tsx för JSX.
Stöd
Genom utvecklingsmiljöerna Node.js och Deno så kan man utveckla, kompilera och köra TypeScript-kod. För Node.js kan man installera TypeScript med mjukvaran npm, pnpm eller Yarn och man definierar sina kompilationsinställningar i en tsconfig.json-fil, men för Deno finns det förinstallerat.
Typannotationer
TypeScript tillåter statisk typning genom typannotationer vilket möjliggör för typcheckning både innan och efter koden utförs.function addera(a: number, b: number): number {
return a + b
}I den första funktionen kan man se att den tar nummer a och nummer b som parametrar. Genom kolonet och typen number så kan vi klargöra att båda är av typen nummer. Man kan också se att själva funktionen returnerar ett nummer genom frasen : number på sidan av den. Ifall man överträder dessa typer får man till exempel felmeddelandet Type 'number' is not assigned to type 'string'.let x: [string, number]
x = [10, "hello"];Exempel på hur TypeScript kan hitta fel innan koden körs.
Deklarationsfiler
När TypeScript-kod kompileras finns det ett val att generera en deklarationsfil med filtillägget .d.ts. som fungerar som ett gränssnitt för komponenterna av den kompilerade JavaScript-koden. I deklarationsfilerna tar kompilatorn bara ut typerna, ingen kod. Detta skapar en renare och mer koncentrerad representation av de olika typerna istället för att ha dem utspridda över flera filer.declare namespace aritmetik {
addera(left: number, right: number): number;
subtahera(left: number, right: number): number;
multiplicera(left: number, right: number): number;
dividera(left: number, right: number): number;
}
tsconfig.json
tsconfig.json är en reserverad fil som används vid kodning i TypeScript. Den använder filtypen JSON och specificerar hur TypeScripts kompilator ska kompilera TypeScript-koden. Här kan man specificera hur olika delar av typsystemet ska fungera och hur felkoder ska hanteras. {
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017",
"esModuleInterop": true,
"types": []
},
"compileOnSave": true,
"include": [
"src"
],
"exclude": [
"node_modules"
],
}
Referenser
Noter
Programvaror 2012
Objekt-baserade programspråk | swedish | 0.720905 |
Pony/src-pony_check-poperator-.txt |
poperator.pony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22class ref Poperator[T] is Iterator[T^]
"""
Iterate over a [Seq](builtin-Seq.md) descructively by `pop`ing its elements.
Once `has_next()` returns `false`, the [Seq](builtin-Seq.md) is empty.
Nominee for the annual pony class-naming awards.
"""
let _seq: Seq[T]
new create(seq: Seq[T]) =>
_seq = seq
new empty() =>
_seq = Array[T](0)
fun ref has_next(): Bool =>
_seq.size() > 0
fun ref next(): T^ ? =>
_seq.pop()?
| pony | 1078272 | https://da.wikipedia.org/wiki/Udvidet%20Backus-Naur%20form | Udvidet Backus-Naur form | Indenfor datalogi er udvidet Backus-Naur form (engelsk extended Backus–Naur form (EBNF)) en familie af metasyntaksnotationer - og enhver af disse kan anvendes til at udtrykke en kontekstfri grammatik. EBNF anvendes til at lave en formel syntaksbeskrivelse af et formelt sprog såsom et programmeringssprog til computere. EBNF er udvidelser til Backus-Naur form (BNF) metasyntaksnotation.
De tidligste EBNF blev udviklet af Niklaus Wirth og indarbejdede nogle af begreberne (med en anden syntaks og notation) fra Wirth syntax notation. Men mange EBNF-varianter er i brug.
International Organization for Standardization vedtog en EBNF-standard (ISO/IEC 14977) i 1996.
Ifølge Vadim Zaytsev bidrog standarden med citat only ended up adding yet another three dialects to the chaos og gjorde opmærksom på mangel på succes, og han gjorde opmærksom på at ISO EBNF ikke en gang blev anvendt i alle ISO standarder. David A. Wheeler argumenterer imod at anvende ISO-standarden når man skal anvende EBNF - og anbefaler at alternative EBNF-notationer overvejes såsom en af W3C Extensible Markup Language (XML) 1.0 (Fifth Edition).
Denne artikel anvender EBNF som specificeret af ISO i eksempler, der gælder for alle EBNF'er. Andre EBNF-varianter anvender lidt andre syntaktiske konventioner.
EBNF kan både anvendes i den leksikalsk analyse og i parseren. (leksikalsk analyse splitter input-tekststrengen op i tokens ("sprogatomer", leksemer) og fjerner typisk whitespace og kodekommentarer.)
Eksempler
Syntaksdiagrammer
EBNF
Selv EBNF kan beskrives ved at anvende EBNF. Betragt den skitserede grammatik herunder baseret på ASCII-tegnsættet (derfor ingen ÆØÅ).
Leksikalsk analyse
Den leksikalske analyse gør følgende: Input (tegn) fås fra en tekstfil. Output-parsetræet er følge af tokens med metadata (whitespace og kommentarer smides typisk ud):
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
| "c" | "d" | "e" | "f" | "g" | "h" | "i"
| "j" | "k" | "l" | "m" | "n" | "o" | "p"
| "q" | "r" | "s" | "t" | "u" | "v" | "w"
| "x" | "y" | "z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
symbol_no_quotes_questionmark =
"[" | "]" | "{" | "}" | "(" | ")" | "<" | ">"
| "=" | "|" | "." | "," | ";" ;
visible_characters_no_quotes_questionmark =
letter | digit | symbol_no_quotes_questionmark | " " | "_" ;
visible_characters_no_quotes = visible_characters_no_quotes_questionmark | "?" ;
visible_characters_no_questionmark = visible_characters_no_quotes_questionmark | "'" | '"' ;
visible_characters = visible_characters_no_questionmark | "?" ;
white_space = "\t" | "\n" | "\r" | " " ;
identifier = letter , { letter | digit | "_" } ;
free-text-special-terminal =
"?" , visible_characters_no_questionmark
, { visible_characters_no_questionmark } , "?"
terminal = "'" , ( visible_characters_no_quotes | '"' )
, { ( visible_characters_no_quotes | '"' ) } , "'"
| '"' , ( visible_characters_no_quotes | "'" )
, { ( visible_characters_no_quotes | "'" ) } , '"'
| free-text-special-terminal ;
token = symbol_no_quotes_questionmark | identifier | terminal | free-text-special-terminal ;
comment = "(*" , visible_characters , { visible_characters } , "*)" ;
comment_or_whitespace = white_space | comment ;
grammar = { comment_or_whitespace } , { token , { comment_or_whitespace } } ;
Parser
Parser: Input (tokens) fås fra den ovenstående leksikalske analyse. Output er et parsetræ:
expression = identifier
| terminal
| "[" , expression , "]"
| "{" , expression , "}"
| "(" , expression , ")"
| expression , "|" , expression
| expression , "," , expression ;
lhs = identifier ;
rule = lhs , "=" , expression , ";" ;
grammar = { rule } ;
Pascal
Et Pascal-lignende programmeringssprog, som kun tillader tildelinger, kan defineres i EBNF med ASCII-tegnsættet som følger.
Leksikalsk analyse
Leksikalsk analyse: Input (tegn) fås fra en tekstfil. Output-parsetræet er en følge af tokens med metadata (whitespace smides typisk ud):
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
white_space = "\t" | "\n" | "\r" | " " ;
symbol_no_quotes = "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">"
| "=" | "|" | "." | "," | ";" | ":=" ;
visible_characters_no_quotes = letter | digit | symbol_no_quotes | " " ;
identifier = letter , { letter | digit } ;
number = [ "-" ] , digit , { digit } ;
textstring = '"' , { visible_characters_no_quotes | "'" } , '"' ;
token = symbol_no_quotes | identifier | number | textstring ;
grammar = { white_space } , { token , { white_space } } ;
Parser
Parser: Input (tokens) fås fra den ovenstående leksikalske analyse. Output er et parsetræ:
assignment = identifier , ":=" , ( number | identifier | textstring ) ;
program = 'PROGRAM', identifier,
'BEGIN',
{ assignment, ";" } ,
'END.' ;
Fx kunne et syntaktisk korrekt program se således ud:
PROGRAM DEMO1
BEGIN
A:=3;
B:=45;
H:=-100023;
C:=A;
D123:=B34A;
BABOON:=GIRAFFE;
TEXT:="Hello world!";
END.
Se også
Attributgrammatik - formelt sprog med semantisk databehandling
Referencer
Implementation af programmeringssprog | danish | 1.056727 |
Pony/strings-CommonPrefix-.txt |
CommonPrefix¶
[Source]
Creates a string that is the common prefix of the supplied strings, possibly
empty.
primitive val CommonPrefix
Constructors¶
create¶
[Source]
new val create()
: CommonPrefix val^
Returns¶
CommonPrefix val^
Public Functions¶
apply¶
[Source]
fun box apply(
data: ReadSeq[Stringable box] box)
: String iso^
Parameters¶
data: ReadSeq[Stringable box] box
Returns¶
String iso^
eq¶
[Source]
fun box eq(
that: CommonPrefix val)
: Bool val
Parameters¶
that: CommonPrefix val
Returns¶
Bool val
ne¶
[Source]
fun box ne(
that: CommonPrefix val)
: Bool val
Parameters¶
that: CommonPrefix val
Returns¶
Bool val
| pony | 476679 | https://no.wikipedia.org/wiki/JSON | JSON | JSON (JavaScript Object Notation, uttales [ˈdʒeɪsən]) er en enkel tekstbasert standard for å formatere dokumenter (meldinger) som brukes for datautveksling. Den er opprinnelig avledet fra JavaScript for å representere enkle datastrukturer. Standarden er imidlertid uavhengig av JavaScript eller andre programmeringsspråk.
JSON-formatet ble opprinnelig spesifisert av Douglas Crockford, i standarden RFC 4627.
JSON blir ofte brukt for å serialisere datastrukturer som sendes over et nettverk, først og fremst mellom en server og en web-applikasjon, dette som et alternativ til XML. JSON har den fordelen fremfor XML at semantisk informasjon bare inngår en gang, mens XML som regel har dobbelt sett med start- og slutt-tag og er derfor mer plasskrevende. JSON har imidlertid en svakere formalisme for verdivalidering enn XML.
JSON er svært godt egnet til bruk i AJAX-applikasjoner.
Datatyper
JSON støtter følgende grunnleggende datatyper:
Tall
Tekst (String)
Boolske verdier
Tabeller
Objekter (nøkkel:verdi-par)
null (tom verdi)
Eksempel
Følgende datastruktur er en JSON-representasjon av et dataobjekt som beskriver en person. Objektet har tekstfelt for navn, et objekt som inneholder adresse og en liste over telefonnummer-objekter.
{
"fornavn": "Ola",
"etternavn": "Nordmann",
"alder": 25,
"adresse":
{
"gateadresse": "Bakken 4",
"postnummer": 1234,
"poststed": "Bakkebygrenda"
},
"telefonnumre":
[
{
"type": "mobil",
"nummer": "912 34 567"
},
{
"type": "hjem",
"nummer": "12 34 56 78"
},
{
"type": "fax",
"nummer": "87 65 43 21"
}
]
}
Eksterne lenker
Filformater | norwegian_bokmål | 0.805948 |
Pony/passing-and-sharing.txt | # Passing and Sharing References
Reference capabilities make it safe to both __pass__ mutable data between actors and to __share__ immutable data amongst actors. Not only that, they make it safe to do it with no copying, no locks, in fact, no runtime overhead at all.
## Passing
For an object to be mutable, we need to be sure that no _other_ actor can read from or write to that object. The three mutable reference capabilities (`iso`, `trn`, and `ref`) all make that guarantee.
But what if we want to pass a mutable object from one actor to another? To do that, we need to be sure that the actor that is _sending_ the mutable object also _gives up_ the ability to both read from and write to that object.
This is exactly what `iso` does. It is _read and write unique_, there can only be one reference at a time that can be used for reading or writing. If you send an `iso` object to another actor, you will be giving up the ability to read from or write to that object.
__So I should use `iso` when I want to pass a mutable object between actors?__ Yes! If you don't need to pass it, you can just use `ref` instead.
## Sharing
If you want to __share__ an object amongst actors, then we have to make one of the following guarantees:
1. Either _no_ actor can write to the object, in which case _any_ actor can read from it, or
2. Only _one_ actor can write to the object, in which case _other_ actors can neither read from or write to the object.
The first guarantee is exactly what `val` does. It is _globally immutable_, so we know that _no_ actor can ever write to that object. As a result, you can freely send `val` objects to other actors, without needing to give up the ability to read from that object.
__So I should use `val` when I want to share an immutable object amongst actors?__ Yes! If you don't need to share it, you can just use `ref` instead, or `box` if you want it to be immutable.
The second guarantee is what `tag` does. Not the part about only one actor writing (that's guaranteed by any mutable reference capability), but the part about not being able to read from or write to an object. That means you can freely pass `tag` objects to other actors, without needing to give up the ability to read from or write to that object.
__What's the point in sending a tag reference to another actor if it can't then read or write the fields?__ Because `tag` __can__ be used to __identify__ objects and sometimes that's all you need. Also, if the object is an actor you can call behaviours on it even though you only have a `tag`.
__So I should use `tag` when I want to share the identity of a mutable object amongst actors?__ Yes! Or, really, the identity of anything, whether it's mutable, immutable, or even an actor.
## Reference capabilities that can't be sent
You may have noticed we didn't mention `trn`, `ref`, or `box` as things you can send to other actors. That's because you can't do it. They don't make the guarantees we need in order to be safe.
So when should you use those reference capabilities?
* Use `ref` when you need to be able to change an object over time. On the other hand, if your program wouldn't be any slower if you used an immutable type instead, you may want to use a `val` anyway.
* Use `box` when you don't care whether the object is mutable or immutable. In other words, you want to be able to read it, but you don't need to write to it or share it with other actors.
* Use `trn` when you want to be able to change an object for a while, but you also want to be able to make it _globally immutable_ later.
| pony | 166930 | https://sv.wikipedia.org/wiki/Klaffel%20%28film%29 | Klaffel (film) | Klaffel eller klaff-fel, kontinuitetsfel, syftar på företeelser inom film och TV som inte stämmer från tagning till tagning. Exempel kan vara en skådespelare som i ena kameravinkeln har en röd tröja och i nästa har en blå tröja.
Etymologi
Begreppet klaf[f-]fel är relaterat till verbet klaffa. När saker inte stämmer (inte klaffar) från en scen till en annan uppstår klaffel.
Funktion
Klaff-fel bryter illusionen av att man tittar på ett verkligt skeende, och ska därför i regel undvikas. (Undantaget är när man som i Den nakna pistolen-filmerna skojar med fenomenet.) Men eftersom inspelningar sällan sker i kronologisk ordning, i ett svep, eller ens på samma plats kan det vara svårt att helt eliminera alla klaff-fel. Inspelningsschemat bestäms ofta av tillträde till inspelningsplatsen. En rollfigur kan återvända till Sergels torg flera gånger under en film, men eftersom det är dyrt att spärra av Sergels torg, spelas de scenerna in i ett sträck.
Det är svårt att rätta till ett klaff-fel när inspelningen väl har slutat. Den person som innan och under inspelningen som har hand om att se till att man undviker klaff-fel på olika sätt är scriptan (på engelska script supervisor eller continuity supervisor – dock är script supervisor vanligare). Jobbet börjar redan innan inspelningen genom att scriptan "bryter ner" manusets tidslinje och identifierar exempelvis hur många dagar historien utspelar sig över och om det finns saker som ska följa med mellan scener. Scriptan lämnar sedan rapporter till de olika avdelningarna, som scenografi, smink, kostym med mera, så att de kan utgå ifrån detta när de avgör vad en karaktär ska ha på sig.
På inspelningen jobbar scriptan med att se till att kontinuiteten håller mellan olika tagningar och kamerainställningar, det görs i samarbete med representanter från de olika avdelningarna. Exempelvis håller en person från kostymavdelningen koll på skådespelarna har rätt kläder på sig för varje scen och under tagningarna håller personen koll på att inget konstigt händer med kläderna och om karaktären tex drar upp ärmarna på tröjan inför en fight, ser kostympersonalen till att kläderna återställs in för nästa tagning och att ärmarna ska vara uppdragna även i nästkommande scen när fighten flyttar till en annan lokal. Det kräver mycket fotografier av allt som finns i bild, anteckningar om rörelsemönster. Polaroid-kameror var vanliga verktyg, men har ersatts av digitalkameror och i vissa fall hårdvara som kopplas mellan monitor och dator och tillåter scriptan att ta screen shots.
Bortsett från klaff-fel, jobbar också scriptan med att se till så att alla delar av manuset blir filmade, skriver rapporter till klipparen och att det som filmas faktiskt går att klippa ihop. Övriga avdelningar jobbar numera ofta med kontinuitetsappar som låter bilder kopplas till karaktärerna och scenerna de har varit med i.
Olika klaff-fel
De flesta klaff-fel som förekommer i filmer är små, såsom hur mycket vatten det finns i en persons glas eller cigaretters längd. Variationer i väderlek (längre skuggor, molnformationer med mera) är ytterst svåra att undvika men märks ofta inte.
Lite större fel (redigerings-klaff) kommer sig av att en tagning överlappar en annan så att rollfiguren ser ut att göra samma sak två gånger. Ett sådant exempel finns i En ding, ding, ding, ding värld när en grupp människor börjar klättra två gånger.
Intrig-klaff handlar om brister i det fiktiva universumet. Till exempel kan en rollfigur i en scen berätta att han var enda barnet och senare presentera sin syster. Ett sådant fel finns i The Cosby show där familjen sades ha 4 barn men ett 5:e dök upp under en Thanksgiving-middag. Eller så kan en rollfigur försvinna spårlöst. Mest berömt är fallet med Chuck Cunningham i TV-serien Gänget och jag som försvann mellan säsong 2 och 3.
Klaff kan vara svårt i komplexa fiktiva världar som skiljer sig väldigt mycket från vår verklighet, såsom i science fiction eller fantasy. Många fiktiva universum, till exempel Star Trek och Stjärnornas krig, är så välkända och detaljerade att det kan vara svårt att skapa nya berättelser som passar in i den etablerade tidslinjen.
Klaff-fel görs ibland medvetet (se retcon). Bobby i Dallas som dog men sen kom ut ur duschen är ett omtalat exempel.
TV-serier som 24, där skådespelarna ska se ut som om det är samma dag i 24 avsnitt i sträck, har gjort tittarna medvetna om vikten av att hålla klaff.
Ibland försöker skaparna ge förklaringar till eller släta över tidigare klaff-fel. I andra fall löses problemet genom att förneka existensen av det avsnitt som innehåller klaff-felet, genom att påstå att det inte tillhör kanon. Att kasta bort all tidigare kontinuitet och börja om från början kallas att reboota. Ett exempel på detta är Bond-filmen Casino Royale, som utspelar sig i nutid, men skildrar James Bonds första uppdrag som 00-agent. En mindre extrem version suddar ut ett avsnitt, vilket kallas resetknapps-tekniken.
I andra medier
Visuella klaff-fel finns i litterära texter också. I Chaucers The Canterbury Tales ("The Millers Tale") finns en scen där en dörr slits av gångjärnen för att lite senare stängas normalt.
Se även
Fiktivt universum
Retcon
Tabbe
Referenser
Externa länkar
http://www.moviemistakes.com/
Klippteknik | swedish | 0.8642 |
Pony/4_traits-and-interfaces.txt | # Traits and Interfaces
Like other object-oriented languages, Pony has __subtyping__. That is, some types serve as _categories_ that other types can be members of.
There are two kinds of __subtyping__ in programming languages: __nominal__ and __structural__. They're subtly different, and most programming languages only have one or the other. Pony has both!
## Nominal subtyping
This kind of subtyping is called __nominal__ because it is all about __names__.
If you've done object-oriented programming before, you may have seen a lot of discussion about _single inheritance_, _multiple inheritance_, _mixins_, _traits_, and similar concepts. These are all examples of __nominal subtyping__.
The core idea is that you have a type that declares it has a relationship to some category type. In Java, for example, a __class__ (a concrete type) can __implement__ an __interface__ (a category type). In Java, this means the class is now in the category that the interface represents. The compiler will check that the class actually provides everything it needs to.
In Pony, nominal subtyping is done via the keyword `is`. `is` declares at the point of declaration that an object has a relationship to a category type. For example, to use nominal subtyping to declare that the class `Name` provides `Stringable`, you'd do:
```pony
class Name is Stringable
```
## Structural subtyping
There's another kind of subtyping, where the name doesn't matter. It's called __structural subtyping__, which means that it's all about how a type is built, and nothing to do with names.
A concrete type is a member of a structural category if it happens to have all the needed elements, no matter what it happens to be called.
Structural typing is very similar to [duck typing](https://en.wikipedia.org/wiki/Duck_typing) from dynamic programming languages, except that type compatibility is determined at compile time rather than at run time. If you've used Go, you'll recognise that Go interfaces are structural types.
You do not declare structural relationships ahead of time, instead it is done by checking if a given concrete type can fulfill the required interface. For example, in the code below, we have the interface `Stringable` from the standard library. Anything can be used as a `Stringable` so long as it provides the method `fun string(): String iso^`. In our example below, `ExecveError` provides the `Stringable` interface and can be used anywhere a `Stringable` is needed. Because `Stringable` is a structural type, `ExecveError` doesn't have to declare a relationship to `Stringable`, it simply has that relationship because it has "the same shape".
```pony
interface box Stringable
"""
Things that can be turned into a String.
"""
fun string(): String iso^
"""
Generate a string representation of this object.
"""
primitive ExecveError
fun string(): String iso^ => "ExecveError".clone()
```
## Nominal and structural subtyping in Pony
When discussing subtyping in Pony, it is common to say that `trait` is nominal subtyping and `interface` is structural subtyping, however, that isn't really true.
Both `trait` and `interface` can establish a relationship via nominal subtyping. Only `interface` can be used for structural subtyping.
### Nominal subtyping in Pony
The primary means of doing nominal subtyping in Pony is using __traits__. A __trait__ looks a bit like a __class__, but it uses the keyword `trait` and it can't have any fields.
```pony
trait Named
fun name(): String => "Bob"
class Bob is Named
```
Here, we have a trait `Named` that has a single function `name` that returns a String. It also provides a default implementation of `name` that returns the string literal "Bob".
We also have a class `Bob` that says it `is Named`. This means `Bob` is in the `Named` category. In Pony, we say _Bob provides Named_, or sometimes simply _Bob is Named_.
Since `Bob` doesn't have its own `name` function, it uses the one from the trait. If the trait's function didn't have a default implementation, the compiler would complain that `Bob` had no implementation of `name`.
```pony
trait Named
fun name(): String => "Bob"
trait Bald
fun hair(): Bool => false
class Bob is (Named & Bald)
```
It is possible for a class to have relationships with multiple categories. In the above example, the class `Bob` _provides both Named and Bald_.
```pony
trait Named
fun name(): String => "Bob"
trait Bald is Named
fun hair(): Bool => false
class Bob is Bald
```
It is also possible to combine categories together. In the example above, all `Bald` classes are automatically `Named`. Consequently, the `Bob` class has access to both hair() and name() default implementation of their respective trait. One can think of the `Bald` category to be more specific than the `Named` one.
```pony
class Larry
fun name(): String => "Larry"
```
Here, we have a class `Larry` that has a `name` function with the same signature. But `Larry` does __not__ provide `Named`!
__Wait, why not?__ Because `Larry` doesn't say it `is Named`. Remember, traits are __nominal__: a type that wants to provide a trait has to explicitly declare that it does. And `Larry` doesn't.
You can also do nominal subtyping using the keyword `interface`. __Interfaces__ in Pony are primarily used for structural subtyping. Like traits, interfaces can also have default method implementations, but in order to use default method implementations, an interface must be used in a nominal fashion. For example:
```pony
interface HasName
fun name(): String => "Bob"
class Bob is HasName
class Larry
fun name(): String => "Larry"
```
Both `Bob` and `Larry` are in the category `HasName`. `Bob` because it has declared that it is a `HasName` and `Larry` because it is structurally a `HasName`.
### Structural subtyping in Pony
Pony has structural subtyping using __interfaces__. Interfaces look like traits, but they use the keyword `interface`.
```pony
interface HasName
fun name(): String
```
Here, `HasName` looks a lot like `Named`, except it's an interface instead of a trait. This means both `Bob` and `Larry` provide `HasName`! The programmers that wrote `Bob` and `Larry` don't even have to be aware that `HasName` exists.
## Differences between traits and interfaces
It is common for new Pony users to ask, __Should I use traits or interfaces in my own code?__ Both! Interfaces are more flexible, so if you're not sure what you want, use an interface. But traits are a powerful tool as well.
### Private methods
A key difference between traits and interfaces is that interfaces can't have private methods. So, if you need private methods, you'll need to use a trait and have users opt in via nominal typing. Interfaces can't have private methods because otherwise, users could use them to break encapsulation and access private methods on concrete types from other packages. For example:
```pony
actor Main
new create(env: Env) =>
let x: String ref = "sailor".string()
let y: Foo = x
y._set(0, 'f')
env.out.print("Hello, " + x)
interface Foo
fun ref _set(i: USize, value: U8): U8
```
In the code above, the interface `Foo` allows access to the private `_set` method of `String` and allows for changing `sailor` to `failor` or it would anyway, if interfaces were allowed to have private methods.
### Open world enumerations
Traits allow you to create "open world enumerations" that others can participate in. For example:
```pony
trait Color
primitive Red is Color
primitive Blue is Color
```
Here we are using a trait to provide a category of things, `Color`, that any other types can opt into by declaring itself to be a `Color`. This creates an "open world" of enumerations that you can't do using the more traditional Pony approach using type unions.
```pony
primitive Red
primitive Blue
type Color is (Red | Blue)
```
In our trait based example, we can add new colors at any time. With the type union based approach, we can only add them by modifying definition of `Color` in the package that provides it.
Interfaces can't be used for open world enumerations. If we defined `Color` as an interface:
```pony
interface Color
```
Then literally everything in Pony would be a `Color` because everything matches the `Color` interface. You can however, do something similar using "marker methods" with an interface:
```pony
interface Color
fun is_color(): None
primitive Red
fun is_color(): None => None
```
Here we are using structural typing to create a collection of things that are in the category `Color` by providing a method that "marks" being a member of the category: `is_color`.
### Open world typing
We've covered a couple ways that traits can be better than interfaces, let's close with the reason for why we say, unless you have a reason to, you should use `interface` instead of `trait`. Interfaces are incredibly flexible. Because traits only provide nominal typing, a concrete type can only be in a category if it was declared as such by the programmer who wrote the concrete type. Interfaces allow you to create your own categorizations on the fly, as you need them, to group existing concrete types together however you need to.
Here's a contrived example:
```pony
interface Compactable
fun ref compact()
fun size(): USize
class Compactor
"""
Compacts data structures when their size crosses a threshold
"""
let _threshold: USize
new create(threshold: USize) =>
_threshold = threshold
fun ref try_compacting(thing: Compactable) =>
if thing.size() > _threshold then
thing.compact()
end
```
The flexibility of `interface` has allowed us to define a type `Compactable` that we can use to allow our `Compactor` to accept a variety of data types including `Array`, `Map`, and `String` from the standard library.
| pony | 4827447 | https://sv.wikipedia.org/wiki/Fagopyrum%20statice | Fagopyrum statice | Fagopyrum statice är en slideväxtart som först beskrevs av Leveille, och fick sitt nu gällande namn av Gross. Fagopyrum statice ingår i släktet boveten, och familjen slideväxter. Inga underarter finns listade i Catalogue of Life.
Källor
Boveten
statice | swedish | 1.24137 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.