@@ -27,18 +27,49 @@ public CritVisitor(string version)
2727 Variables [ "Sum" ] = new Func < object ? [ ] , object ? > ( SumArr ) ;
2828 Variables [ "Add" ] = new Func < object ? [ ] , object ? > ( AddArr ) ;
2929 Variables [ "Remove" ] = new Func < object ? [ ] , object ? > ( RemoveArr ) ;
30- Variables [ "Len" ] = new Func < object ? [ ] , object ? > ( LenArr ) ;
3130
3231 //OS Functions
3332 Variables [ "ReadText" ] = new Func < object ? [ ] , object ? > ( ReadText ) ;
33+ //Variables["Time"] = new Func<object?[], object?>(Time);
3434
3535 //Gerenal Functions
3636 Variables [ "Convert" ] = new Func < object ? [ ] , object ? > ( ConvertTo ) ;
37+ Variables [ "Delay" ] = new Func < object ? [ ] , object ? > ( Delay ) ;
3738 Variables [ "CritVersion" ] = _version ;
39+ Variables [ "Split" ] = new Func < object ? [ ] , object ? > ( Split ) ;
40+ Variables [ "Len" ] = new Func < object ? [ ] , object ? > ( Len ) ;
3841
3942 }
4043
4144
45+
46+ public static object ? Split ( object ? [ ] args )
47+ {
48+ if ( args . Length != 2 ) throw new Exception ( "Delay takes 2 arguments." ) ;
49+ object [ ] ? ol = args [ 0 ] ? . ToString ( ) ? . Split ( args [ 1 ] ! . ToString ( ) ! . ToCharArray ( ) ) ;
50+ return ol ? . ToList ( ) ;
51+ }
52+
53+ public static object ? Delay ( object ? [ ] args )
54+ {
55+ if ( args . Length != 1 ) throw new Exception ( "Delay takes 1 argument" ) ;
56+ Task . Delay ( ( int ) args [ 0 ] ! ) . Wait ( ) ;
57+ return null ;
58+
59+ }
60+
61+ //TODO FIX THIS
62+ //public static object? Time(object?[] args)
63+ //{
64+ // if (args.Length != 0) throw new Exception("Time takes no arguments");
65+
66+ // //TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
67+ // //double timestamp = t.TotalMilliseconds;
68+ // //return Math.Round(timestamp / 1000, 2);
69+ // //int m = DateTime.Now.Millisecond;
70+ // return DateTime.Now;
71+ //}
72+
4273 public static object ? ReadText ( object ? [ ] args )
4374 {
4475 if ( args . Length != 1 ) throw new Exception ( "ReadText expects 1 argument" ) ;
@@ -51,8 +82,6 @@ public CritVisitor(string version)
5182 {
5283 throw new Exception ( "ReadText failed: " + e . Message ) ;
5384 }
54-
55-
5685 }
5786
5887
@@ -112,16 +141,17 @@ public CritVisitor(string version)
112141 ? throw new Exception ( "Pow expects 2 arguments." )
113142 : ( float ) ( Math . Pow ( Convert . ToSingle ( args [ 0 ] ! ) , Convert . ToSingle ( args [ 1 ] ! ) ) ) ;
114143
115- private static object ? LenArr ( object ? [ ] args )
144+ private static object ? Len ( object ? [ ] args )
116145 {
117146 if ( args . Length is not 1 )
118147 throw new Exception ( "Len expects 1 argument" ) ;
119148
120- if ( args [ 0 ] is List < object > arr )
121- return arr . Count ;
122-
123- return new Exception ( "Len expects an array" ) ;
124-
149+ return args [ 0 ] switch
150+ {
151+ List < object > arr => arr . Count ,
152+ string str => str . Length ,
153+ _ => new Exception ( "Len expects an array or string" )
154+ } ;
125155 }
126156
127157
0 commit comments