Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Operators #3

Open
26 tasks
TheAwiteb opened this issue Mar 16, 2023 · 0 comments
Open
26 tasks

Operators #3

TheAwiteb opened this issue Mar 16, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@TheAwiteb
Copy link
Owner

TheAwiteb commented Mar 16, 2023

Mathematical operators

  • add A function that adds two numbers.
  • sub A function that subtracts two numbers.
  • mul A function that multiplies two numbers.
  • div A function that divides two numbers.
  • mod A function that returns the remainder of two numbers.
  • pow A function that raises a number to the power of another number.
  • neg A function that negates a number.
  • abs A function that returns the absolute value of a number.

Logical operators

  • not A function that performs a logical NOT operation.
  • and A function that performs a logical AND operation.
  • or A function that performs a logical OR operation.

Comparison operators

  • eq A function that compares two values for equality.
  • ne A function that compares two values for inequality.
  • lt A function that compares two values for less-than.
  • gt A function that compares two values for greater-than.
  • le A function that compares two values for less-than-or-equal.
  • ge A function that compares two values for greater-than-or-equal.

Lists operators

  • all A function that checks if all elements of a list satisfy a predicate.
  • any A function that checks if any element of a list satisfies a predicate.
  • concat A function that concatenates two lists.
  • contains A function that checks if a list contains an element.
  • drop A function that drops the first n elements of a list.
  • drop_while A function that drops the first n elements of a list that satisfy a predicate.
  • filter A function that filters a list based on a predicate.
  • find A function that finds the first element of a list that satisfies a predicate.
  • find_index A function that finds the first index of a list that satisfies a predicate.

Notes

All this functions will be implemented after OOP is implemented. Because they will be implemented as magic methods, they will be implemented in the Object class.

Magic methods

The magic methods are the methods that are called when an operator is used on an object. For example, when you use the add operator on two numbers, the __add__ method is called.

@TheAwiteb TheAwiteb self-assigned this Mar 16, 2023
@TheAwiteb TheAwiteb added the enhancement New feature or request label Mar 16, 2023
@TheAwiteb TheAwiteb modified the milestones: v0.2.0, v0.3.0 Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant