We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List/sum(list)
@spec List/sum(List[Number]) -> Number
Calculates the sum of all numbers in the given list.
list
Returns the sum of all numbers in the list.
Possible (but not limited to) errors:
InvalidType
# Sum an empty list result = List/sum([]) # 0
# Sum a list of integers result = List/sum([1, 2, 3, 4, 5]) # 15
# Sum a list of floats result = List/sum([1.5, 2.7, 3.2]) # 7.4
# Attempt to sum a list with non-numeric elements result = List/sum([1, 2, "3", 4]) # InvalidType: List contains non-numeric elements
List/range(start, stop, step=1)
@spec List/range(int, int, int) -> List[int]
Generates a list of integers from start to stop (exclusive) with a given step.
start
stop
step
Returns a list of integers.
InvalidValue
# Generate a simple range result = List/range(0, 5) # [0, 1, 2, 3, 4]
# Generate a range with a custom step result = List/range(0, 10, 2) # [0, 2, 4, 6, 8]
# Generate a descending range result = List/range(5, 0, -1) # [5, 4, 3, 2, 1]
# Attempt to create a range with a step 0 result = List/range(0, 5, 0) # `InvalidValue`: Step cannot be zero
# Create an empty range result = List/range(0, 0) # []
List/range
List/sum
The text was updated successfully, but these errors were encountered:
Sipher
Successfully merging a pull request may close this issue.
1.
List/sum(list)
Calculates the sum of all numbers in the given list.
Parameters
list
: A list of numbers (integers or floats)Returns the sum of all numbers in the list.
Possible (but not limited to) errors:
InvalidType
: If the list contains non-numeric elementsExamples
2.
List/range(start, stop, step=1)
Generates a list of integers from
start
tostop
(exclusive) with a givenstep
.Parameters
start
: The starting value of the range (inclusive)stop
: The ending value of the range (exclusive)step
: The difference between each number in the range (default is 1)Returns a list of integers.
Possible (but not limited to) errors:
InvalidValue
: If step is 0, or if the range would never terminateExamples
Considerations
List/range
with large rangesList/sum
, consider using an appropriate numeric type to avoid overflow for large sumsList/sum
List/range
, consider memory efficiency for large rangesTest cases to implement
The text was updated successfully, but these errors were encountered: