WeixiangYan/CodeTransOcean huggingface dataset:
Task: Sum digits of an integer



C#: namespace RosettaCode.SumDigitsOfAnInteger
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    internal static class Program
    {
        
        
        
        
        
        
        
        
        
        private static IEnumerable<int> Digits(this int number, int @base = 10)
        {
            while (number != 0)
            {
                int digit;
                number = Math.DivRem(number, @base, out digit);
                yield return digit;
            }
        }

        
        
        
        
        
        
        private static int SumOfDigits(this int number, int @base = 10)
        {
            return number.Digits(@base).Sum();
        }

        
        
        
        private static void Main()
        {
            foreach (var example in
                new[]
                {
                    new {Number = 1, Base = 10},
                    new {Number = 12345, Base = 10},
                    new {Number = 123045, Base = 10},
                    new {Number = 0xfe, Base = 0x10},
                    new {Number = 0xf0e, Base = 0x10}
                })
            {
                Console.WriteLine(example.Number.SumOfDigits(example.Base));
            }
        }
    }
}






VB: Function sumDigits(num As Variant, base As Long) As Long
    
    Dim outp As Long
    Dim validNums As String, tmp As Variant, x As Long, lennum As Long
    
    validNums = Left$("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", base)
    lennum = Len(num)
    For L0 = lennum To 1 Step -1
        x = InStr(validNums, Mid$(num, L0, 1)) - 1
        If -1 = x Then Exit Function
        tmp = tmp + (x * (base ^ (lennum - L0)))
    Next
    While tmp
        outp = outp + (tmp Mod base)
        tmp = tmp \ base
    Wend
    sumDigits = outp
End Function

Sub tester()
    Debug.Print sumDigits(1, 10)
    Debug.Print sumDigits(1234, 10)
    Debug.Print sumDigits(&HFE, 16)
    Debug.Print sumDigits(&HF0E, 16)
    Debug.Print sumDigits("2", 2)
End Sub
Task: Sum digits of an integer

C: #include <stdio.h>

int SumDigits(unsigned long long n, const int base) {
    int sum = 0;
    for (; n; n /= base)
    	sum += n % base;
    return sum;
}
 
int main() {
    printf("%d %d %d %d %d\n",
        SumDigits(1, 10),
        SumDigits(12345, 10),
        SumDigits(123045, 10),
        SumDigits(0xfe, 16),
        SumDigits(0xf0e, 16) );
    return 0;
}






PHP: <?php
function sumDigits($num, $base = 10) {
    $s = base_convert($num, 10, $base);
    foreach (str_split($s) as $c)
        $result += intval($c, $base);
    return $result;
}
echo sumDigits(1), "\n";
echo sumDigits(12345), "\n";
echo sumDigits(123045), "\n";
echo sumDigits(0xfe, 16), "\n";
echo sumDigits(0xf0e, 16), "\n";
?>
Task: Sum digits of an integer



C#: namespace RosettaCode.SumDigitsOfAnInteger
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    internal static class Program
    {
        
        
        
        
        
        
        
        
        
        private static IEnumerable<int> Digits(this int number, int @base = 10)
        {
            while (number != 0)
            {
                int digit;
                number = Math.DivRem(number, @base, out digit);
                yield return digit;
            }
        }

        
        
        
        
        
        
        private static int SumOfDigits(this int number, int @base = 10)
        {
            return number.Digits(@base).Sum();
        }

        
        
        
        private static void Main()
        {
            foreach (var example in
                new[]
                {
                    new {Number = 1, Base = 10},
                    new {Number = 12345, Base = 10},
                    new {Number = 123045, Base = 10},
                    new {Number = 0xfe, Base = 0x10},
                    new {Number = 0xf0e, Base = 0x10}
                })
            {
                Console.WriteLine(example.Number.SumOfDigits(example.Base));
            }
        }
    }
}




PHP: <?php
function sumDigits($num, $base = 10) {
    $s = base_convert($num, 10, $base);
    foreach (str_split($s) as $c)
        $result += intval($c, $base);
    return $result;
}
echo sumDigits(1), "\n";
echo sumDigits(12345), "\n";
echo sumDigits(123045), "\n";
echo sumDigits(0xfe, 16), "\n";
echo sumDigits(0xf0e, 16), "\n";
?>
Task: Sum digits of an integer


C++: #include <iostream>
#include <cmath>
int SumDigits(const unsigned long long int digits, const int BASE = 10) {
    int sum = 0;
    unsigned long long int x = digits;
    for (int i = log(digits)/log(BASE); i>0; i--){
        const double z = std::pow(BASE,i);
	  const unsigned long long int t = x/z;
	  sum += t;
	  x -= t*z;
    }
    return x+sum;
}

int main() {
        std::cout << SumDigits(1) << ' '
                  << SumDigits(12345) << ' '
                  << SumDigits(123045) << ' '
                  << SumDigits(0xfe, 16) << ' '
                  << SumDigits(0xf0e, 16) << std::endl;
        return 0;
}





PHP: <?php
function sumDigits($num, $base = 10) {
    $s = base_convert($num, 10, $base);
    foreach (str_split($s) as $c)
        $result += intval($c, $base);
    return $result;
}
echo sumDigits(1), "\n";
echo sumDigits(12345), "\n";
echo sumDigits(123045), "\n";
echo sumDigits(0xfe, 16), "\n";
echo sumDigits(0xf0e, 16), "\n";
?>
Task: Sum digits of an integer




Go: 

package digit

import (
	"math/big"
	"strconv"
)

func SumString(n string, base int) (int, error) {
	i, ok := new(big.Int).SetString(n, base)
	if !ok {
		return 0, strconv.ErrSyntax
	}
	if i.Sign() < 0 {
		return 0, strconv.ErrRange
	}
	if i.BitLen() <= 64 {
		return Sum(i.Uint64(), base), nil
	}
	return SumBig(i, base), nil
}

func Sum(i uint64, base int) (sum int) {
	b64 := uint64(base)
	for ; i > 0; i /= b64 {
		sum += int(i % b64)
	}
	return
}

func SumBig(n *big.Int, base int) (sum int) {
	i := new(big.Int).Set(n)
	b := new(big.Int).SetUint64(uint64(base))
	r := new(big.Int)
	for i.BitLen() > 0 {
		i.DivMod(i, b, r)
		sum += int(r.Uint64())
	}
	return
}



PHP: <?php
function sumDigits($num, $base = 10) {
    $s = base_convert($num, 10, $base);
    foreach (str_split($s) as $c)
        $result += intval($c, $base);
    return $result;
}
echo sumDigits(1), "\n";
echo sumDigits(12345), "\n";
echo sumDigits(123045), "\n";
echo sumDigits(0xfe, 16), "\n";
echo sumDigits(0xf0e, 16), "\n";
?>
Task: Sum digits of an integer






PHP: <?php
function sumDigits($num, $base = 10) {
    $s = base_convert($num, 10, $base);
    foreach (str_split($s) as $c)
        $result += intval($c, $base);
    return $result;
}
echo sumDigits(1), "\n";
echo sumDigits(12345), "\n";
echo sumDigits(123045), "\n";
echo sumDigits(0xfe, 16), "\n";
echo sumDigits(0xf0e, 16), "\n";
?>


Python: 




நிரல்பாகம் எண்_கூட்டல்( எண் )
  தொகை = 0
  @( எண் > 0 ) வரை
     d = எண்%10;
     பதிப்பி "digit = ",d
     எண் = (எண்-d)/10;
     தொகை  = தொகை  + d
  முடி
  பின்கொடு தொகை 
முடி


பதிப்பி எண்_கூட்டல்( 1289)
பதிப்பி எண்_கூட்டல்( 123456789)
Task: Sum digits of an integer






PHP: <?php
function sumDigits($num, $base = 10) {
    $s = base_convert($num, 10, $base);
    foreach (str_split($s) as $c)
        $result += intval($c, $base);
    return $result;
}
echo sumDigits(1), "\n";
echo sumDigits(12345), "\n";
echo sumDigits(123045), "\n";
echo sumDigits(0xfe, 16), "\n";
echo sumDigits(0xf0e, 16), "\n";
?>



VB: function SumDigits(number, nBase)
    if number < 0 then number = -1 * number 
    if nBase < 2 then nBase = 2             
    sum = 0
    while number > 0
        sum = sum + (number mod nBase)
        number = int(number / nBase)
    wend
    SumDigits = sum
end function

print "The sums of the digits are:\n"
print "1    base 10 : "; SumDigits(1, 10)
print "1234 base 10 : "; SumDigits(1234, 10)
print "fe   base 16 : "; SumDigits(hexdec("FE"), 16)
print "f0e  base 16 : "; SumDigits(hexdec("F0E"), 16)
end
Task: Array length

C: #include <stdio.h>

int main()
{    
    const char *fruit[2] = { "apples", "oranges" };

    
    

    
    
    

    
    
    int length = sizeof(fruit) / sizeof(fruit[0]);

    printf("%d\n", length);

    return 0;
}



C#: using System;

namespace ArrayLength
{
  class Program
  {
    public static void Main()
    {
      var array = new String[]("apple", "orange");
      Console.WriteLine(array.Count);
      delete(array);
    }
  }
}
Task: Array length

C: #include <stdio.h>

int main()
{    
    const char *fruit[2] = { "apples", "oranges" };

    
    

    
    
    

    
    
    int length = sizeof(fruit) / sizeof(fruit[0]);

    printf("%d\n", length);

    return 0;
}


C++: #include <array>
#include <iostream>
#include <string>

int main() 
{
    std::array<std::string, 2> fruit { "apples", "oranges" };
    std::cout << fruit.size();
    return 0;
}
Task: Array length

C: #include <stdio.h>

int main()
{    
    const char *fruit[2] = { "apples", "oranges" };

    
    

    
    
    

    
    
    int length = sizeof(fruit) / sizeof(fruit[0]);

    printf("%d\n", length);

    return 0;
}







Python: arr = ['apple', 'orange']  

def setup():
    println(len(arr))
Task: Array length

C: #include <stdio.h>

int main()
{    
    const char *fruit[2] = { "apples", "oranges" };

    
    

    
    
    

    
    
    int length = sizeof(fruit) / sizeof(fruit[0]);

    printf("%d\n", length);

    return 0;
}








VB: Debug.Print "Array Length: " & UBound(Array("apple", "orange")) + 1
Task: Array length


C++: #include <array>
#include <iostream>
#include <string>

int main() 
{
    std::array<std::string, 2> fruit { "apples", "oranges" };
    std::cout << fruit.size();
    return 0;
}


C#: using System;

namespace ArrayLength
{
  class Program
  {
    public static void Main()
    {
      var array = new String[]("apple", "orange");
      Console.WriteLine(array.Count);
      delete(array);
    }
  }
}
Task: Array length


C++: #include <array>
#include <iostream>
#include <string>

int main() 
{
    std::array<std::string, 2> fruit { "apples", "oranges" };
    std::cout << fruit.size();
    return 0;
}






Python: arr = ['apple', 'orange']  

def setup():
    println(len(arr))
Task: Array length


C++: #include <array>
#include <iostream>
#include <string>

int main() 
{
    std::array<std::string, 2> fruit { "apples", "oranges" };
    std::cout << fruit.size();
    return 0;
}







VB: Debug.Print "Array Length: " & UBound(Array("apple", "orange")) + 1
Task: Array length



C#: using System;

namespace ArrayLength
{
  class Program
  {
    public static void Main()
    {
      var array = new String[]("apple", "orange");
      Console.WriteLine(array.Count);
      delete(array);
    }
  }
}





Python: arr = ['apple', 'orange']  

def setup():
    println(len(arr))
Task: Array length



C#: using System;

namespace ArrayLength
{
  class Program
  {
    public static void Main()
    {
      var array = new String[]("apple", "orange");
      Console.WriteLine(array.Count);
      delete(array);
    }
  }
}






VB: Debug.Print "Array Length: " & UBound(Array("apple", "orange")) + 1
Task: Array length







Python: arr = ['apple', 'orange']  

def setup():
    println(len(arr))


VB: Debug.Print "Array Length: " & UBound(Array("apple", "orange")) + 1
Task: Array length

C: #include <stdio.h>

int main()
{    
    const char *fruit[2] = { "apples", "oranges" };

    
    

    
    
    

    
    
    int length = sizeof(fruit) / sizeof(fruit[0]);

    printf("%d\n", length);

    return 0;
}






PHP: print count(['apple', 'orange']); // Returns 2
Task: Array length



C#: using System;

namespace ArrayLength
{
  class Program
  {
    public static void Main()
    {
      var array = new String[]("apple", "orange");
      Console.WriteLine(array.Count);
      delete(array);
    }
  }
}




PHP: print count(['apple', 'orange']); // Returns 2
Task: Array length


C++: #include <array>
#include <iostream>
#include <string>

int main() 
{
    std::array<std::string, 2> fruit { "apples", "oranges" };
    std::cout << fruit.size();
    return 0;
}





PHP: print count(['apple', 'orange']); // Returns 2
Task: Array length






PHP: print count(['apple', 'orange']); // Returns 2


Python: arr = ['apple', 'orange']  

def setup():
    println(len(arr))
Task: Array length






PHP: print count(['apple', 'orange']); // Returns 2



VB: Debug.Print "Array Length: " & UBound(Array("apple", "orange")) + 1
Task: Hostname

C: #include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
 
int main(void)
{
 char name[_POSIX_HOST_NAME_MAX + 1];
 return gethostname(name, sizeof name) == -1 || printf("%s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}



C#: System.Net.Dns.GetHostName();
Task: Hostname

C: #include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
 
int main(void)
{
 char name[_POSIX_HOST_NAME_MAX + 1];
 return gethostname(name, sizeof name) == -1 || printf("%s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}




Go: package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Println(os.Hostname())
}
Task: Hostname

C: #include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
 
int main(void)
{
 char name[_POSIX_HOST_NAME_MAX + 1];
 return gethostname(name, sizeof name) == -1 || printf("%s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}





Java: import java.net.*;
class DiscoverHostName {
 public static void main(final String[] args) {
  try {
   System.out.println(InetAddress.getLocalHost().getHostName());
  } catch (UnknownHostException e) { 
  }
 }
}
Task: Hostname

C: #include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
 
int main(void)
{
 char name[_POSIX_HOST_NAME_MAX + 1];
 return gethostname(name, sizeof name) == -1 || printf("%s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}







Python: import socket
host = socket.gethostname()
Task: Hostname

C: #include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
 
int main(void)
{
 char name[_POSIX_HOST_NAME_MAX + 1];
 return gethostname(name, sizeof name) == -1 || printf("%s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}








VB: Set objNetwork = CreateObject("WScript.Network")
WScript.Echo objNetwork.ComputerName
Task: Hostname



C#: System.Net.Dns.GetHostName();


Go: package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Println(os.Hostname())
}
Task: Hostname



C#: System.Net.Dns.GetHostName();



Java: import java.net.*;
class DiscoverHostName {
 public static void main(final String[] args) {
  try {
   System.out.println(InetAddress.getLocalHost().getHostName());
  } catch (UnknownHostException e) { 
  }
 }
}
Task: Hostname




Go: package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Println(os.Hostname())
}


Java: import java.net.*;
class DiscoverHostName {
 public static void main(final String[] args) {
  try {
   System.out.println(InetAddress.getLocalHost().getHostName());
  } catch (UnknownHostException e) { 
  }
 }
}
Task: Hostname





Java: import java.net.*;
class DiscoverHostName {
 public static void main(final String[] args) {
  try {
   System.out.println(InetAddress.getLocalHost().getHostName());
  } catch (UnknownHostException e) { 
  }
 }
}



Python: import socket
host = socket.gethostname()
Task: Hostname





Java: import java.net.*;
class DiscoverHostName {
 public static void main(final String[] args) {
  try {
   System.out.println(InetAddress.getLocalHost().getHostName());
  } catch (UnknownHostException e) { 
  }
 }
}




VB: Set objNetwork = CreateObject("WScript.Network")
WScript.Echo objNetwork.ComputerName
Task: Hostname




Go: package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Println(os.Hostname())
}





VB: Set objNetwork = CreateObject("WScript.Network")
WScript.Echo objNetwork.ComputerName
Task: Hostname




Go: package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Println(os.Hostname())
}




Python: import socket
host = socket.gethostname()
Task: Hostname

C: #include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
 
int main(void)
{
 char name[_POSIX_HOST_NAME_MAX + 1];
 return gethostname(name, sizeof name) == -1 || printf("%s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}






PHP: echo $_SERVER['HTTP_HOST'];
Task: Hostname




Go: package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Println(os.Hostname())
}



PHP: echo $_SERVER['HTTP_HOST'];
Task: Hostname





Java: import java.net.*;
class DiscoverHostName {
 public static void main(final String[] args) {
  try {
   System.out.println(InetAddress.getLocalHost().getHostName());
  } catch (UnknownHostException e) { 
  }
 }
}


PHP: echo $_SERVER['HTTP_HOST'];
Task: Greatest element of a list

C: #include <assert.h>

float max(unsigned int count, float values[]) {
     assert(count > 0);
     size_t idx;
     float themax = values[0];
     for(idx = 1; idx < count; ++idx) {
          themax = values[idx] > themax ? values[idx] : themax;
     }
     return themax;
}



C#: int[] values = new int[] {1,2,3,4,5,6,7,8,9,10};

int max = values.Max();
Task: Greatest element of a list

C: #include <assert.h>

float max(unsigned int count, float values[]) {
     assert(count > 0);
     size_t idx;
     float themax = values[0];
     for(idx = 1; idx < count; ++idx) {
          themax = values[idx] > themax ? values[idx] : themax;
     }
     return themax;
}


C++: #include <algorithm>  
#include <iterator>   
#include <functional> 

template<class It, class Comp = std::less<>>
    
constexpr auto max_value(It first, It last, Comp compare = std::less{})
{
    
    return *std::max_element(first, last, compare);
}

template<class C, class Comp = std::less<>>
    
constexpr auto max_value(const C& container, Comp compare = std::less{})
{
    
    using std::begin; using std::end;
    return max_value(begin(container), end(container), compare);
}
Task: Greatest element of a list

C: #include <assert.h>

float max(unsigned int count, float values[]) {
     assert(count > 0);
     size_t idx;
     float themax = values[0];
     for(idx = 1; idx < count; ++idx) {
          themax = values[idx] > themax ? values[idx] : themax;
     }
     return themax;
}




Go: package main

import (
    "fmt"

    "github.com/gonum/floats"
)

func main() {
	fmt.Println(floats.Max([]float64{63, 70, 37, 34, 83, 27, 19, 97, 9, 17})) 
	fmt.Println(floats.Min([]float64{63, 70, 37, 34, 83, 27, 19, 97, 9, 17})) 
}
Task: Greatest element of a list

C: #include <assert.h>

float max(unsigned int count, float values[]) {
     assert(count > 0);
     size_t idx;
     float themax = values[0];
     for(idx = 1; idx < count; ++idx) {
          themax = values[idx] > themax ? values[idx] : themax;
     }
     return themax;
}







Python: max(values)
Task: Greatest element of a list


C++: #include <algorithm>  
#include <iterator>   
#include <functional> 

template<class It, class Comp = std::less<>>
    
constexpr auto max_value(It first, It last, Comp compare = std::less{})
{
    
    return *std::max_element(first, last, compare);
}

template<class C, class Comp = std::less<>>
    
constexpr auto max_value(const C& container, Comp compare = std::less{})
{
    
    using std::begin; using std::end;
    return max_value(begin(container), end(container), compare);
}


C#: int[] values = new int[] {1,2,3,4,5,6,7,8,9,10};

int max = values.Max();
Task: Greatest element of a list


C++: #include <algorithm>  
#include <iterator>   
#include <functional> 

template<class It, class Comp = std::less<>>
    
constexpr auto max_value(It first, It last, Comp compare = std::less{})
{
    
    return *std::max_element(first, last, compare);
}

template<class C, class Comp = std::less<>>
    
constexpr auto max_value(const C& container, Comp compare = std::less{})
{
    
    using std::begin; using std::end;
    return max_value(begin(container), end(container), compare);
}




Java: public static float max(float[] values) throws NoSuchElementException {
    if (values.length == 0)
        throw new NoSuchElementException();
    float themax = values[0];
    for (int idx = 1; idx < values.length; ++idx) {
        if (values[idx] > themax)
            themax = values[idx];
    }
    return themax;
}
Task: Greatest element of a list


C++: #include <algorithm>  
#include <iterator>   
#include <functional> 

template<class It, class Comp = std::less<>>
    
constexpr auto max_value(It first, It last, Comp compare = std::less{})
{
    
    return *std::max_element(first, last, compare);
}

template<class C, class Comp = std::less<>>
    
constexpr auto max_value(const C& container, Comp compare = std::less{})
{
    
    using std::begin; using std::end;
    return max_value(begin(container), end(container), compare);
}






Python: max(values)
Task: Greatest element of a list


C++: #include <algorithm>  
#include <iterator>   
#include <functional> 

template<class It, class Comp = std::less<>>
    
constexpr auto max_value(It first, It last, Comp compare = std::less{})
{
    
    return *std::max_element(first, last, compare);
}

template<class C, class Comp = std::less<>>
    
constexpr auto max_value(const C& container, Comp compare = std::less{})
{
    
    using std::begin; using std::end;
    return max_value(begin(container), end(container), compare);
}







VB: functioni FindMax(...) as double
    dim x as integer
        
    for x = 1 to ParamValCount
        IF ParamVal(x) > Result THEN Result = ParamVal(x)
    next
End functioni

Print FindMax(50, 20, 65, 20, 105)
Task: Greatest element of a list



C#: int[] values = new int[] {1,2,3,4,5,6,7,8,9,10};

int max = values.Max();





Python: max(values)
Task: Greatest element of a list



C#: int[] values = new int[] {1,2,3,4,5,6,7,8,9,10};

int max = values.Max();






VB: functioni FindMax(...) as double
    dim x as integer
        
    for x = 1 to ParamValCount
        IF ParamVal(x) > Result THEN Result = ParamVal(x)
    next
End functioni

Print FindMax(50, 20, 65, 20, 105)
Task: Greatest element of a list





Java: public static float max(float[] values) throws NoSuchElementException {
    if (values.length == 0)
        throw new NoSuchElementException();
    float themax = values[0];
    for (int idx = 1; idx < values.length; ++idx) {
        if (values[idx] > themax)
            themax = values[idx];
    }
    return themax;
}



Python: max(values)
Task: Greatest element of a list




Go: package main

import (
    "fmt"

    "github.com/gonum/floats"
)

func main() {
	fmt.Println(floats.Max([]float64{63, 70, 37, 34, 83, 27, 19, 97, 9, 17})) 
	fmt.Println(floats.Min([]float64{63, 70, 37, 34, 83, 27, 19, 97, 9, 17})) 
}




Python: max(values)
Task: Greatest element of a list




Go: package main

import (
    "fmt"

    "github.com/gonum/floats"
)

func main() {
	fmt.Println(floats.Max([]float64{63, 70, 37, 34, 83, 27, 19, 97, 9, 17})) 
	fmt.Println(floats.Min([]float64{63, 70, 37, 34, 83, 27, 19, 97, 9, 17})) 
}





VB: functioni FindMax(...) as double
    dim x as integer
        
    for x = 1 to ParamValCount
        IF ParamVal(x) > Result THEN Result = ParamVal(x)
    next
End functioni

Print FindMax(50, 20, 65, 20, 105)
Task: Greatest element of a list







Python: max(values)


VB: functioni FindMax(...) as double
    dim x as integer
        
    for x = 1 to ParamValCount
        IF ParamVal(x) > Result THEN Result = ParamVal(x)
    next
End functioni

Print FindMax(50, 20, 65, 20, 105)
Task: Greatest element of a list

C: #include <assert.h>

float max(unsigned int count, float values[]) {
     assert(count > 0);
     size_t idx;
     float themax = values[0];
     for(idx = 1; idx < count; ++idx) {
          themax = values[idx] > themax ? values[idx] : themax;
     }
     return themax;
}








VB: functioni FindMax(...) as double
    dim x as integer
        
    for x = 1 to ParamValCount
        IF ParamVal(x) > Result THEN Result = ParamVal(x)
    next
End functioni

Print FindMax(50, 20, 65, 20, 105)