From 7a30e2635c14d37f05c3722ebf0332332d6703db Mon Sep 17 00:00:00 2001 From: Alessandro Date: Fri, 10 Sep 2021 12:23:05 +0200 Subject: [PATCH] unsorted_arguments --- README.md | 7 +++++++ src/TermInterface.jl | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 922f597..ab57248 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,13 @@ Construct a new term with the operation `f` and arguments `args`, the term shoul ### Optional +#### `unsorted_arguments(x)` + +If x is a term satisfying `istree(x)` and your term type `T` orovides +and optimized implementation for storing the arguments, this function can +be used to retrieve the arguments when the order of arguments does not matter +but the speed of the operation does. Defaults to `arguments(x)`. + #### `symtype(x)` The supposed type of values in the domain of x. Tracing tools can use this type to diff --git a/src/TermInterface.jl b/src/TermInterface.jl index 7b8253f..a1111f8 100644 --- a/src/TermInterface.jl +++ b/src/TermInterface.jl @@ -66,6 +66,19 @@ Get the arguments of `x`, must be defined if `istree(x)` is `true`. function arguments end export arguments + +""" + unsorted_arguments(x::T) + +If x is a term satisfying `istree(x)` and your term type `T` orovides +and optimized implementation for storing the arguments, this function can +be used to retrieve the arguments when the order of arguments does not matter +but the speed of the operation does. +""" +unsorted_arguments(x) = arguments(x) +export unsorted_arguments + + """ arity(x)