WeixiangYan/CodeTransOcean huggingface dataset:
Task: Feigenbaum constant calculation





Java: public class Feigenbaum {
    public static void main(String[] args) {
        int max_it = 13;
        int max_it_j = 10;
        double a1 = 1.0;
        double a2 = 0.0;
        double d1 = 3.2;
        double a;

        System.out.println(" i       d");
        for (int i = 2; i <= max_it; i++) {
            a = a1 + (a1 - a2) / d1;
            for (int j = 0; j < max_it_j; j++) {
                double x = 0.0;
                double y = 0.0;
                for (int k = 0; k < 1 << i; k++) {
                    y = 1.0 - 2.0 * y * x;
                    x = a - x * x;
                }
                a -= x / y;
            }
            double d = (a1 - a2) / (a - a1);
            System.out.printf("%2d    %.8f\n", i, d);
            d1 = d;
            a2 = a1;
            a1 = a;
        }
    }
}







Ada: with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Main is
   procedure feigenbaum is
      subtype i_range is Integer range 2 .. 13;
      subtype j_range is Integer range 1 .. 10;

      
      
      

      type Real is digits 15;
      package Real_Io is new Float_IO (Real);
      use Real_Io;

      a, x, y, d : Real;
      a1         : Real := 1.0;
      a2         : Real := 0.0;
      d1         : Real := 3.2;
   begin
      Put_Line (" i       d");
      for i in i_range loop
         a := a1 + (a1 - a2) / d1;
         for j in j_range loop
            x := 0.0;
            y := 0.0;
            for k in 1 .. 2**i loop
               y := 1.0 - 2.0 * x * y;
               x := a - x * x;
            end loop;
            a := a - x / y;
         end loop;
         d := (a1 - a2) / (a - a1);
         Put (Item => i, Width => 2);
         Put (Item => d, Fore => 5, Aft => 8, Exp => 0);
         New_Line;
         d1 := d;
         a2 := a1;
         a1 := a;
      end loop;
   end feigenbaum;

begin
   feigenbaum;
end Main;
Task: Feigenbaum constant calculation







Python: max_it = 13
max_it_j = 10
a1 = 1.0
a2 = 0.0
d1 = 3.2
a = 0.0

print " i       d"
for i in range(2, max_it + 1):
    a = a1 + (a1 - a2) / d1
    for j in range(1, max_it_j + 1):
        x = 0.0
        y = 0.0
        for k in range(1, (1 << i) + 1):
            y = 1.0 - 2.0 * y * x
            x = a - x * x
        a = a - x / y
    d = (a1 - a2) / (a - a1)
    print("{0:2d}    {1:.8f}".format(i, d))
    d1 = d
    a2 = a1
    a1 = a





Ada: with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Main is
   procedure feigenbaum is
      subtype i_range is Integer range 2 .. 13;
      subtype j_range is Integer range 1 .. 10;

      
      
      

      type Real is digits 15;
      package Real_Io is new Float_IO (Real);
      use Real_Io;

      a, x, y, d : Real;
      a1         : Real := 1.0;
      a2         : Real := 0.0;
      d1         : Real := 3.2;
   begin
      Put_Line (" i       d");
      for i in i_range loop
         a := a1 + (a1 - a2) / d1;
         for j in j_range loop
            x := 0.0;
            y := 0.0;
            for k in 1 .. 2**i loop
               y := 1.0 - 2.0 * x * y;
               x := a - x * x;
            end loop;
            a := a - x / y;
         end loop;
         d := (a1 - a2) / (a - a1);
         Put (Item => i, Width => 2);
         Put (Item => d, Fore => 5, Aft => 8, Exp => 0);
         New_Line;
         d1 := d;
         a2 := a1;
         a1 := a;
      end loop;
   end feigenbaum;

begin
   feigenbaum;
end Main;
Task: Feigenbaum constant calculation








VB: Module Module1

    Sub Main()
        Dim maxIt = 13
        Dim maxItJ = 10
        Dim a1 = 1.0
        Dim a2 = 0.0
        Dim d1 = 3.2
        Console.WriteLine(" i       d")
        For i = 2 To maxIt
            Dim a = a1 + (a1 - a2) / d1
            For j = 1 To maxItJ
                Dim x = 0.0
                Dim y = 0.0
                For k = 1 To 1 << i
                    y = 1.0 - 2.0 * y * x
                    x = a - x * x
                Next
                a -= x / y
            Next
            Dim d = (a1 - a2) / (a - a1)
            Console.WriteLine("{0,2:d}    {1:f8}", i, d)
            d1 = d
            a2 = a1
            a1 = a
        Next
    End Sub

End Module




Ada: with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Main is
   procedure feigenbaum is
      subtype i_range is Integer range 2 .. 13;
      subtype j_range is Integer range 1 .. 10;

      
      
      

      type Real is digits 15;
      package Real_Io is new Float_IO (Real);
      use Real_Io;

      a, x, y, d : Real;
      a1         : Real := 1.0;
      a2         : Real := 0.0;
      d1         : Real := 3.2;
   begin
      Put_Line (" i       d");
      for i in i_range loop
         a := a1 + (a1 - a2) / d1;
         for j in j_range loop
            x := 0.0;
            y := 0.0;
            for k in 1 .. 2**i loop
               y := 1.0 - 2.0 * x * y;
               x := a - x * x;
            end loop;
            a := a - x / y;
         end loop;
         d := (a1 - a2) / (a - a1);
         Put (Item => i, Width => 2);
         Put (Item => d, Fore => 5, Aft => 8, Exp => 0);
         New_Line;
         d1 := d;
         a2 := a1;
         a1 := a;
      end loop;
   end feigenbaum;

begin
   feigenbaum;
end Main;
Task: Feigenbaum constant calculation

C: #include <stdio.h>

void feigenbaum() {
    int i, j, k, max_it = 13, max_it_j = 10;
    double a, x, y, d, a1 = 1.0, a2 = 0.0, d1 = 3.2;
    printf(" i       d\n");
    for (i = 2; i <= max_it; ++i) {
        a = a1 + (a1 - a2) / d1;
        for (j = 1; j <= max_it_j; ++j) {
            x = 0.0;
            y = 0.0;
            for (k = 1; k <= 1 << i; ++k) {
                 y = 1.0 - 2.0 * y * x;
                 x = a - x * x;
            }
            a -= x / y;
        }
        d = (a1 - a2) / (a - a1);
        printf("%2d    %.8f\n", i, d);
        d1 = d;
        a2 = a1;
        a1 = a;
    }
}

int main() {
    feigenbaum();
    return 0;
}
Task: Feigenbaum constant calculation



C#: using System;

namespace FeigenbaumConstant {
    class Program {
        static void Main(string[] args) {
            var maxIt = 13;
            var maxItJ = 10;
            var a1 = 1.0;
            var a2 = 0.0;
            var d1 = 3.2;
            Console.WriteLine(" i       d");
            for (int i = 2; i <= maxIt; i++) {
                var a = a1 + (a1 - a2) / d1;
                for (int j = 1; j <= maxItJ; j++) {
                    var x = 0.0;
                    var y = 0.0;
                    for (int k = 1; k <= 1<<i; k++) {
                        y = 1.0 - 2.0 * y * x;
                        x = a - x * x;
                    }
                    a -= x / y;
                }
                var d = (a1 - a2) / (a - a1);
                Console.WriteLine("{0,2:d}    {1:f8}", i, d);
                d1 = d;
                a2 = a1;
                a1 = a;
            }
        }
    }
}
Task: Feigenbaum constant calculation


C++: #include <iostream>

int main() {
    const int max_it = 13;
    const int max_it_j = 10;
    double a1 = 1.0, a2 = 0.0, d1 = 3.2;

    std::cout << " i       d\n";
    for (int i = 2; i <= max_it; ++i) {
        double a = a1 + (a1 - a2) / d1;
        for (int j = 1; j <= max_it_j; ++j) {
            double x = 0.0;
            double y = 0.0;
            for (int k = 1; k <= 1 << i; ++k) {
                y = 1.0 - 2.0*y*x;
                x = a - x * x;
            }
            a -= x / y;
        }
        double d = (a1 - a2) / (a - a1);
        printf("%2d    %.8f\n", i, d);
        d1 = d;
        a2 = a1;
        a1 = a;
    }

    return 0;
}
Task: Feigenbaum constant calculation





Java: public class Feigenbaum {
    public static void main(String[] args) {
        int max_it = 13;
        int max_it_j = 10;
        double a1 = 1.0;
        double a2 = 0.0;
        double d1 = 3.2;
        double a;

        System.out.println(" i       d");
        for (int i = 2; i <= max_it; i++) {
            a = a1 + (a1 - a2) / d1;
            for (int j = 0; j < max_it_j; j++) {
                double x = 0.0;
                double y = 0.0;
                for (int k = 0; k < 1 << i; k++) {
                    y = 1.0 - 2.0 * y * x;
                    x = a - x * x;
                }
                a -= x / y;
            }
            double d = (a1 - a2) / (a - a1);
            System.out.printf("%2d    %.8f\n", i, d);
            d1 = d;
            a2 = a1;
            a1 = a;
        }
    }
}
Task: Feigenbaum constant calculation







Python: max_it = 13
max_it_j = 10
a1 = 1.0
a2 = 0.0
d1 = 3.2
a = 0.0

print " i       d"
for i in range(2, max_it + 1):
    a = a1 + (a1 - a2) / d1
    for j in range(1, max_it_j + 1):
        x = 0.0
        y = 0.0
        for k in range(1, (1 << i) + 1):
            y = 1.0 - 2.0 * y * x
            x = a - x * x
        a = a - x / y
    d = (a1 - a2) / (a - a1)
    print("{0:2d}    {1:.8f}".format(i, d))
    d1 = d
    a2 = a1
    a1 = a
Task: Feigenbaum constant calculation








VB: Module Module1

    Sub Main()
        Dim maxIt = 13
        Dim maxItJ = 10
        Dim a1 = 1.0
        Dim a2 = 0.0
        Dim d1 = 3.2
        Console.WriteLine(" i       d")
        For i = 2 To maxIt
            Dim a = a1 + (a1 - a2) / d1
            For j = 1 To maxItJ
                Dim x = 0.0
                Dim y = 0.0
                For k = 1 To 1 << i
                    y = 1.0 - 2.0 * y * x
                    x = a - x * x
                Next
                a -= x / y
            Next
            Dim d = (a1 - a2) / (a - a1)
            Console.WriteLine("{0,2:d}    {1:f8}", i, d)
            d1 = d
            a2 = a1
            a1 = a
        Next
    End Sub

End Module
Task: Feigenbaum constant calculation




Go: package main

import "fmt"

func feigenbaum() {
    maxIt, maxItJ := 13, 10
    a1, a2, d1 := 1.0, 0.0, 3.2
    fmt.Println(" i       d")
    for i := 2; i <= maxIt; i++ {
        a := a1 + (a1-a2)/d1
        for j := 1; j <= maxItJ; j++ {
            x, y := 0.0, 0.0
            for k := 1; k <= 1<<uint(i); k++ {
                y = 1.0 - 2.0*y*x
                x = a - x*x
            }
            a -= x / y
        }
        d := (a1 - a2) / (a - a1)
        fmt.Printf("%2d    %.8f\n", i, d)
        d1, a2, a1 = d, a1, a
    }
}

func main() {
    feigenbaum()
}
Task: Feigenbaum constant calculation



C#: using System;

namespace FeigenbaumConstant {
    class Program {
        static void Main(string[] args) {
            var maxIt = 13;
            var maxItJ = 10;
            var a1 = 1.0;
            var a2 = 0.0;
            var d1 = 3.2;
            Console.WriteLine(" i       d");
            for (int i = 2; i <= maxIt; i++) {
                var a = a1 + (a1 - a2) / d1;
                for (int j = 1; j <= maxItJ; j++) {
                    var x = 0.0;
                    var y = 0.0;
                    for (int k = 1; k <= 1<<i; k++) {
                        y = 1.0 - 2.0 * y * x;
                        x = a - x * x;
                    }
                    a -= x / y;
                }
                var d = (a1 - a2) / (a - a1);
                Console.WriteLine("{0,2:d}    {1:f8}", i, d);
                d1 = d;
                a2 = a1;
                a1 = a;
            }
        }
    }
}








Fortran:       program feigenbaum
      implicit none

      integer i, j, k
      real ( KIND = 16 ) x, y, a, b, a1, a2, d1

      print '(a4,a13)', 'i', 'd'

      a1 = 1.0;
      a2 = 0.0;
      d1 = 3.2;

      do i=2,20
         a = a1 + (a1 - a2) / d1;
         do j=1,10
            x = 0
            y = 0
            do k=1,2**i
                y = 1 - 2 * y * x;
                x = a - x**2;
            end do
            a = a - x / y;
         end do

         d1 = (a1 - a2) / (a - a1);
         a2 = a1;
         a1 = a;
         print '(i4,f13.10)', i, d1
     end do
     end
Task: Feigenbaum constant calculation


C++: #include <iostream>

int main() {
    const int max_it = 13;
    const int max_it_j = 10;
    double a1 = 1.0, a2 = 0.0, d1 = 3.2;

    std::cout << " i       d\n";
    for (int i = 2; i <= max_it; ++i) {
        double a = a1 + (a1 - a2) / d1;
        for (int j = 1; j <= max_it_j; ++j) {
            double x = 0.0;
            double y = 0.0;
            for (int k = 1; k <= 1 << i; ++k) {
                y = 1.0 - 2.0*y*x;
                x = a - x * x;
            }
            a -= x / y;
        }
        double d = (a1 - a2) / (a - a1);
        printf("%2d    %.8f\n", i, d);
        d1 = d;
        a2 = a1;
        a1 = a;
    }

    return 0;
}









Fortran:       program feigenbaum
      implicit none

      integer i, j, k
      real ( KIND = 16 ) x, y, a, b, a1, a2, d1

      print '(a4,a13)', 'i', 'd'

      a1 = 1.0;
      a2 = 0.0;
      d1 = 3.2;

      do i=2,20
         a = a1 + (a1 - a2) / d1;
         do j=1,10
            x = 0
            y = 0
            do k=1,2**i
                y = 1 - 2 * y * x;
                x = a - x**2;
            end do
            a = a - x / y;
         end do

         d1 = (a1 - a2) / (a - a1);
         a2 = a1;
         a1 = a;
         print '(i4,f13.10)', i, d1
     end do
     end
Task: Feigenbaum constant calculation

C: #include <stdio.h>

void feigenbaum() {
    int i, j, k, max_it = 13, max_it_j = 10;
    double a, x, y, d, a1 = 1.0, a2 = 0.0, d1 = 3.2;
    printf(" i       d\n");
    for (i = 2; i <= max_it; ++i) {
        a = a1 + (a1 - a2) / d1;
        for (j = 1; j <= max_it_j; ++j) {
            x = 0.0;
            y = 0.0;
            for (k = 1; k <= 1 << i; ++k) {
                 y = 1.0 - 2.0 * y * x;
                 x = a - x * x;
            }
            a -= x / y;
        }
        d = (a1 - a2) / (a - a1);
        printf("%2d    %.8f\n", i, d);
        d1 = d;
        a2 = a1;
        a1 = a;
    }
}

int main() {
    feigenbaum();
    return 0;
}










Fortran:       program feigenbaum
      implicit none

      integer i, j, k
      real ( KIND = 16 ) x, y, a, b, a1, a2, d1

      print '(a4,a13)', 'i', 'd'

      a1 = 1.0;
      a2 = 0.0;
      d1 = 3.2;

      do i=2,20
         a = a1 + (a1 - a2) / d1;
         do j=1,10
            x = 0
            y = 0
            do k=1,2**i
                y = 1 - 2 * y * x;
                x = a - x**2;
            end do
            a = a - x / y;
         end do

         d1 = (a1 - a2) / (a - a1);
         a2 = a1;
         a1 = a;
         print '(i4,f13.10)', i, d1
     end do
     end
Task: Feigenbaum constant calculation





Java: public class Feigenbaum {
    public static void main(String[] args) {
        int max_it = 13;
        int max_it_j = 10;
        double a1 = 1.0;
        double a2 = 0.0;
        double d1 = 3.2;
        double a;

        System.out.println(" i       d");
        for (int i = 2; i <= max_it; i++) {
            a = a1 + (a1 - a2) / d1;
            for (int j = 0; j < max_it_j; j++) {
                double x = 0.0;
                double y = 0.0;
                for (int k = 0; k < 1 << i; k++) {
                    y = 1.0 - 2.0 * y * x;
                    x = a - x * x;
                }
                a -= x / y;
            }
            double d = (a1 - a2) / (a - a1);
            System.out.printf("%2d    %.8f\n", i, d);
            d1 = d;
            a2 = a1;
            a1 = a;
        }
    }
}






Fortran:       program feigenbaum
      implicit none

      integer i, j, k
      real ( KIND = 16 ) x, y, a, b, a1, a2, d1

      print '(a4,a13)', 'i', 'd'

      a1 = 1.0;
      a2 = 0.0;
      d1 = 3.2;

      do i=2,20
         a = a1 + (a1 - a2) / d1;
         do j=1,10
            x = 0
            y = 0
            do k=1,2**i
                y = 1 - 2 * y * x;
                x = a - x**2;
            end do
            a = a - x / y;
         end do

         d1 = (a1 - a2) / (a - a1);
         a2 = a1;
         a1 = a;
         print '(i4,f13.10)', i, d1
     end do
     end
Task: Feigenbaum constant calculation







Python: max_it = 13
max_it_j = 10
a1 = 1.0
a2 = 0.0
d1 = 3.2
a = 0.0

print " i       d"
for i in range(2, max_it + 1):
    a = a1 + (a1 - a2) / d1
    for j in range(1, max_it_j + 1):
        x = 0.0
        y = 0.0
        for k in range(1, (1 << i) + 1):
            y = 1.0 - 2.0 * y * x
            x = a - x * x
        a = a - x / y
    d = (a1 - a2) / (a - a1)
    print("{0:2d}    {1:.8f}".format(i, d))
    d1 = d
    a2 = a1
    a1 = a




Fortran:       program feigenbaum
      implicit none

      integer i, j, k
      real ( KIND = 16 ) x, y, a, b, a1, a2, d1

      print '(a4,a13)', 'i', 'd'

      a1 = 1.0;
      a2 = 0.0;
      d1 = 3.2;

      do i=2,20
         a = a1 + (a1 - a2) / d1;
         do j=1,10
            x = 0
            y = 0
            do k=1,2**i
                y = 1 - 2 * y * x;
                x = a - x**2;
            end do
            a = a - x / y;
         end do

         d1 = (a1 - a2) / (a - a1);
         a2 = a1;
         a1 = a;
         print '(i4,f13.10)', i, d1
     end do
     end
Task: Feigenbaum constant calculation








VB: Module Module1

    Sub Main()
        Dim maxIt = 13
        Dim maxItJ = 10
        Dim a1 = 1.0
        Dim a2 = 0.0
        Dim d1 = 3.2
        Console.WriteLine(" i       d")
        For i = 2 To maxIt
            Dim a = a1 + (a1 - a2) / d1
            For j = 1 To maxItJ
                Dim x = 0.0
                Dim y = 0.0
                For k = 1 To 1 << i
                    y = 1.0 - 2.0 * y * x
                    x = a - x * x
                Next
                a -= x / y
            Next
            Dim d = (a1 - a2) / (a - a1)
            Console.WriteLine("{0,2:d}    {1:f8}", i, d)
            d1 = d
            a2 = a1
            a1 = a
        Next
    End Sub

End Module



Fortran:       program feigenbaum
      implicit none

      integer i, j, k
      real ( KIND = 16 ) x, y, a, b, a1, a2, d1

      print '(a4,a13)', 'i', 'd'

      a1 = 1.0;
      a2 = 0.0;
      d1 = 3.2;

      do i=2,20
         a = a1 + (a1 - a2) / d1;
         do j=1,10
            x = 0
            y = 0
            do k=1,2**i
                y = 1 - 2 * y * x;
                x = a - x**2;
            end do
            a = a - x / y;
         end do

         d1 = (a1 - a2) / (a - a1);
         a2 = a1;
         a1 = a;
         print '(i4,f13.10)', i, d1
     end do
     end
Task: Memory allocation



C#: using System;
using System.Runtime.InteropServices;

public unsafe class Program
{
    public static unsafe void HeapMemory()
    {
        const int HEAP_ZERO_MEMORY = 0x00000008;
        const int size = 1000;
        int ph = GetProcessHeap();
        void* pointer = HeapAlloc(ph, HEAP_ZERO_MEMORY, size);
        if (pointer == null)
            throw new OutOfMemoryException();
        Console.WriteLine(HeapSize(ph, 0, pointer));
        HeapFree(ph, 0, pointer);
    }

    public static unsafe void StackMemory()
    {
        byte* buffer = stackalloc byte[1000];
        
    }
    public static void Main(string[] args)
    {
        HeapMemory();
        StackMemory();
    }
    [DllImport("kernel32")]
    static extern void* HeapAlloc(int hHeap, int flags, int size);
    [DllImport("kernel32")]
    static extern bool HeapFree(int hHeap, int flags, void* block);
    [DllImport("kernel32")]
    static extern int GetProcessHeap();
    [DllImport("kernel32")]
    static extern int HeapSize(int hHeap, int flags, void* block);

}









Ada: declare
   X : Integer; 
begin
   ...
end;
Task: Memory allocation

C: #include <stdlib.h>


#define SIZEOF_MEMB (sizeof(int))
#define NMEMB 100

int main()
{
  int *ints = malloc(SIZEOF_MEMB*NMEMB);
  
  ints = realloc(ints, sizeof(int)*(NMEMB+1));
  
  int *int2 = calloc(NMEMB, SIZEOF_MEMB);
  
  free(ints); free(int2);
  return 0;
}











Ada: declare
   X : Integer; 
begin
   ...
end;
Task: Memory allocation


C++: #include <string>

int main()
{
  int* p;

  p = new int;    
  delete p;       

  p = new int(2); 
  delete p;       

  std::string* p2;

  p2 = new std::string; 
  delete p2;            

  p = new int[10]; 
  delete[] p;      

  p2 = new std::string[10]; 
  delete[] p2;              
}










Ada: declare
   X : Integer; 
begin
   ...
end;
Task: Memory allocation




Go: func inc(n int) {
    x := n + 1
    println(x)
}








Ada: declare
   X : Integer; 
begin
   ...
end;
Task: Memory allocation





Java: 

Object foo = new Object(); 
int[] fooArray = new int[size]; 
int x = 0; 







Ada: declare
   X : Integer; 
begin
   ...
end;
Task: Memory allocation







Python: >>> from array import array
>>> argslist = [('l', []), ('c', 'hello world'), ('u', u'hello \u2641'),
	('l', [1, 2, 3, 4, 5]), ('d', [1.0, 2.0, 3.14])]
>>> for typecode, initializer in argslist:
	a = array(typecode, initializer)
	print a
	del a

	
array('l')
array('c', 'hello world')
array('u', u'hello \u2641')
array('l', [1, 2, 3, 4, 5])
array('d', [1.0, 2.0, 3.1400000000000001])
>>>





Ada: declare
   X : Integer; 
begin
   ...
end;
Task: Memory allocation

C: #include <stdlib.h>


#define SIZEOF_MEMB (sizeof(int))
#define NMEMB 100

int main()
{
  int *ints = malloc(SIZEOF_MEMB*NMEMB);
  
  ints = realloc(ints, sizeof(int)*(NMEMB+1));
  
  int *int2 = calloc(NMEMB, SIZEOF_MEMB);
  
  free(ints); free(int2);
  return 0;
}
Task: Memory allocation



C#: using System;
using System.Runtime.InteropServices;

public unsafe class Program
{
    public static unsafe void HeapMemory()
    {
        const int HEAP_ZERO_MEMORY = 0x00000008;
        const int size = 1000;
        int ph = GetProcessHeap();
        void* pointer = HeapAlloc(ph, HEAP_ZERO_MEMORY, size);
        if (pointer == null)
            throw new OutOfMemoryException();
        Console.WriteLine(HeapSize(ph, 0, pointer));
        HeapFree(ph, 0, pointer);
    }

    public static unsafe void StackMemory()
    {
        byte* buffer = stackalloc byte[1000];
        
    }
    public static void Main(string[] args)
    {
        HeapMemory();
        StackMemory();
    }
    [DllImport("kernel32")]
    static extern void* HeapAlloc(int hHeap, int flags, int size);
    [DllImport("kernel32")]
    static extern bool HeapFree(int hHeap, int flags, void* block);
    [DllImport("kernel32")]
    static extern int GetProcessHeap();
    [DllImport("kernel32")]
    static extern int HeapSize(int hHeap, int flags, void* block);

}
Task: Memory allocation


C++: #include <string>

int main()
{
  int* p;

  p = new int;    
  delete p;       

  p = new int(2); 
  delete p;       

  std::string* p2;

  p2 = new std::string; 
  delete p2;            

  p = new int[10]; 
  delete[] p;      

  p2 = new std::string[10]; 
  delete[] p2;              
}
Task: Memory allocation





Java: 

Object foo = new Object(); 
int[] fooArray = new int[size]; 
int x = 0;
Task: Memory allocation







Python: >>> from array import array
>>> argslist = [('l', []), ('c', 'hello world'), ('u', u'hello \u2641'),
	('l', [1, 2, 3, 4, 5]), ('d', [1.0, 2.0, 3.14])]
>>> for typecode, initializer in argslist:
	a = array(typecode, initializer)
	print a
	del a

	
array('l')
array('c', 'hello world')
array('u', u'hello \u2641')
array('l', [1, 2, 3, 4, 5])
array('d', [1.0, 2.0, 3.1400000000000001])
>>>
Task: Memory allocation




Go: func inc(n int) {
    x := n + 1
    println(x)
}