Package hydra.lib.strings
Class MaybeCharAt
- java.lang.Object
-
- hydra.tools.PrimitiveFunction
-
- hydra.lib.strings.MaybeCharAt
-
public class MaybeCharAt extends PrimitiveFunction
Get the character at a given index in a string, returning Nothing if the index is out of bounds.
-
-
Constructor Summary
Constructors Constructor Description MaybeCharAt()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.function.Function<java.lang.String,Optional<java.lang.Integer>>apply(java.lang.Integer index)Returns a function that retrieves the character at the given index.static Optional<java.lang.Integer>apply(java.lang.Integer index, java.lang.String s)Get the character at the given index in the string.protected java.util.function.Function<java.util.List<Term>,java.util.function.Function<InferenceContext,java.util.function.Function<Graph,Either<Error_,Term>>>>implementation()A dynamic/interpreted implementation of the function.Namename()The unique name of the primitive function.TypeSchemetype()The datatype of the primitive function.-
Methods inherited from class hydra.tools.PrimitiveFunction
lazyParams, term, toNative
-
-
-
-
Method Detail
-
name
public Name name()
Description copied from class:PrimitiveFunctionThe unique name of the primitive function.- Specified by:
namein classPrimitiveFunction- Returns:
- the name of this primitive function
-
type
public TypeScheme type()
Description copied from class:PrimitiveFunctionThe datatype of the primitive function.- Specified by:
typein classPrimitiveFunction- Returns:
- the type scheme of this primitive function
-
implementation
protected java.util.function.Function<java.util.List<Term>,java.util.function.Function<InferenceContext,java.util.function.Function<Graph,Either<Error_,Term>>>> implementation()
Description copied from class:PrimitiveFunctionA dynamic/interpreted implementation of the function. Subclasses implement this with Either-based logic.- Specified by:
implementationin classPrimitiveFunction- Returns:
- the function implementation
-
apply
public static java.util.function.Function<java.lang.String,Optional<java.lang.Integer>> apply(java.lang.Integer index)
Returns a function that retrieves the character at the given index.- Parameters:
index- the index of the character to retrieve- Returns:
- a function that takes a string and returns a Optional containing the code point at the index
-
apply
public static Optional<java.lang.Integer> apply(java.lang.Integer index, java.lang.String s)
Get the character at the given index in the string.- Parameters:
index- the index of the character to retrieves- the string to query- Returns:
- a Optional containing the code point at the index, or empty if out of bounds
-
-