mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Update .len for subarray to not require ()
This commit is contained in:
@@ -46,7 +46,7 @@ func void encode(char[] in, char *out)
|
||||
{
|
||||
int j = 0;
|
||||
char c = LUT_ENC[1];
|
||||
for (int i = 0; i < in.len(); i++)
|
||||
for (int i = 0; i < in.len; i++)
|
||||
{
|
||||
switch (i % 3)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ func void encode(char[] in, char *out)
|
||||
}
|
||||
|
||||
// move back
|
||||
usize last = in.len() - 1;
|
||||
usize last = in.len - 1;
|
||||
// check the last and add padding
|
||||
switch (last % 3)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ func int! decode(char[] in, char* out, int* invalid_char_index = null)
|
||||
{
|
||||
int j = 0;
|
||||
|
||||
for (int i = 0; i < in.len(); i++)
|
||||
for (int i = 0; i < in.len; i++)
|
||||
{
|
||||
char value = in[i];
|
||||
if (value == PAD) return j;
|
||||
@@ -100,13 +100,13 @@ func int! decode(char[] in, char* out, int* invalid_char_index = null)
|
||||
case 1:
|
||||
out[j++] += c >> 4 & 0x3;
|
||||
// if not last char with padding
|
||||
if (i < (in.len() - 3) || in[(long)(in.len()) - 2] != PAD)
|
||||
if (i < (in.len - 3) || in[(long)(in.len) - 2] != PAD)
|
||||
{
|
||||
out[j] = (c & 0xF) << 4;
|
||||
}
|
||||
case 2:
|
||||
out[j++] += c >> 2 & 0xF;
|
||||
if (i < (in.len() - 2) || in[(long)(in.len()) - 1] != PAD)
|
||||
if (i < (in.len - 2) || in[(long)(in.len) - 1] != PAD)
|
||||
{
|
||||
out[j] = (c & 0x3) << 6;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ const LINELEN = 60;
|
||||
// slowest character-at-a-time output
|
||||
func void repeat_fasta(char[] seq, int n)
|
||||
{
|
||||
usize len = seq.len();
|
||||
usize len = seq.len;
|
||||
int i = void;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
@@ -69,8 +69,8 @@ func void repeat_fasta(char[] seq, int n)
|
||||
|
||||
func void random_fasta(char[] symb, double[] probability, int n)
|
||||
{
|
||||
assert(symb.len() == probability.len());
|
||||
int len = (int)(probability.len());
|
||||
assert(symb.len == probability.len);
|
||||
int len = probability.len;
|
||||
int i = void;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ struct Planet
|
||||
|
||||
func void advance(Planet[] bodies) @noinline
|
||||
{
|
||||
usize nbodies = bodies.len();
|
||||
usize nbodies = bodies.len;
|
||||
foreach (i, Planet* &b : bodies)
|
||||
{
|
||||
for (usize j = i + 1; j < nbodies; j++)
|
||||
@@ -45,7 +45,7 @@ func void advance(Planet[] bodies) @noinline
|
||||
func double energy(Planet[] bodies)
|
||||
{
|
||||
double e;
|
||||
usize nbodies = bodies.len();
|
||||
usize nbodies = bodies.len;
|
||||
|
||||
foreach (i, Planet* &b : bodies)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@ func int levenshtein(String s, String t)
|
||||
{
|
||||
// if either string is empty, difference is inserting all chars
|
||||
// from the other
|
||||
if (!s.len()) return t.len();
|
||||
if (!t.len()) return s.len();
|
||||
if (!s.len) return t.len;
|
||||
if (!t.len) return s.len;
|
||||
|
||||
// if last letters are the same, the difference is whatever is
|
||||
// required to edit the rest of the strings
|
||||
|
||||
Reference in New Issue
Block a user