Skip to content

Commit

Permalink
Adapt place method to use ordinals
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Oct 30, 2024
1 parent 0349ab2 commit 1b965e6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/rudiments-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ extension [ElemType](array: Array[ElemType])
System.arraycopy(array, 0, newArray, 0, array.length)
newArray.immutable(using Unsafe)

inline def place(value: IArray[ElemType], index: Int = 0): Unit =
System.arraycopy(value.asInstanceOf[Array[ElemType]], 0, array, index, value.length)
inline def place(value: IArray[ElemType], ordinal: Ordinal = Prim): Unit =
System.arraycopy(value.asInstanceOf[Array[ElemType]], 0, array, ordinal.n0, value.length)

extension [KeyType, ValueType](map: sc.Map[KeyType, ValueType])
inline def has(key: KeyType): Boolean = map.contains(key)
Expand Down Expand Up @@ -279,7 +279,6 @@ extension [ElemType](seq: IndexedSeq[ElemType])
Cursor.curse(seq)(block)

transparent inline def has(index: Int): Boolean = index >= 0 && index < seq.length
inline def ult: Optional[ElemType] = if seq.length > 0 then seq(seq.length - 1) else Unset

extension (iarray: IArray.type)
def create[ElemType: ClassTag](size: Int)(lambda: Array[ElemType] => Unit): IArray[ElemType] =
Expand Down Expand Up @@ -327,6 +326,16 @@ def homeDirectory[PathType](using directory: HomeDirectory, specific: SpecificPa

directory.path[PathType]

extension [ValueType: Countable](inline value: ValueType)
inline def ult: Optional[Ordinal] =
if ValueType.size(value) >= 1 then Ordinal.zerary(ValueType.size(value) - 1) else Unset

inline def pen: Optional[Ordinal] =
if ValueType.size(value) >= 1 then Ordinal.zerary(ValueType.size(value) - 2) else Unset

inline def ant: Optional[Ordinal] =
if ValueType.size(value) >= 1 then Ordinal.zerary(ValueType.size(value) - 3) else Unset

package workingDirectories:
given default: WorkingDirectory = () => System.getProperty("user.dir").nn.tt
//given none(using Tactic[WorkingDirectoryError]): WorkingDirectory = () => abort(WorkingDirectoryError())
Expand Down

0 comments on commit 1b965e6

Please sign in to comment.