This repository has been archived by the owner on Oct 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8846a6f
commit ee8b7f7
Showing
9 changed files
with
131 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Text; | ||
|
||
namespace Rockstar.Engine.Values; | ||
|
||
public class Array(Source source) | ||
: Value(source) { | ||
private readonly Dictionary<Value, Value> entries = new(); | ||
|
||
public Array(Value[] args) : this(Source.None) { | ||
for (var i = 0; i < args.Length; i++) entries.Add(new Number(i), args[i]); | ||
} | ||
|
||
public override bool Truthy => entries.Count > 0; | ||
|
||
public Value Length | ||
=> new Number(1 + this.entries.Keys.Where(k => k is Number) | ||
.Select(k => (int) ((Number) k).NumericValue) | ||
.Max()); | ||
|
||
public Value Set(Value index, Value value) | ||
=> entries[index] = value; | ||
|
||
public Value Get(Value index) | ||
=> entries.TryGetValue(index, out var value) ? value : Mysterious.Instance; | ||
|
||
public Strïng Join(string joiner) { | ||
return new Strïng(String.Join(joiner, this.entries.Where(e => e.Key is Number) | ||
.OrderBy(k => ((Number) k.Key).NumericValue) | ||
.Select(k => k.Value.ToString()).ToArray())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<ProjectConfiguration> | ||
<Settings> | ||
<DefaultTestTimeout>5000</DefaultTestTimeout> | ||
<DefaultTestTimeout>1000</DefaultTestTimeout> | ||
</Settings> | ||
</ProjectConfiguration> |