Tag: interpreted language

Multidimensional List Solution

In a previous article, I wrote about how it was difficult to produce a 2D list in Copper due to the ownership dilemma. The solution at the time was to write a singly-linked list in Copper. It turns out, there is a better approach, one that will also allow us to create any multi-dimensional list.

Continue reading “Multidimensional List Solution”

Multidimensional List Access Problem

Suppose you wanted to create a 2-dimensional list. This can be easily done with the list constructor. ex:

mylist = list(list(9))

Now suppose we wanted to access the item in the second dimension of the list. Lists are special in that they are objects that contain other objects without themselves containing variables. To access an item in the list, we use the item_at() system function. This returns an object. Performing it once will return the child list. From there, we can call item_at() in succession to access the item of interest:

myitem = item_at(item_at(mylist: 0) 0)

Continue reading “Multidimensional List Access Problem”

output(File:)

After deliberating over the matter, I’ve decided that it’d be best to write an extension for Copper that would enable file reading and writing. This would enable the language to finally be general purpose, putting it among the big boys like Python. While the current Copper VM is certainly not fast enough to compete, the ease, power, and syntax of the language make it a highly tempting alternative.

Continue reading “output(File:)”

Take a Byte of Copper

A very simple byte extension was added to Copper’s extension collection recently. It’s just a convenience class with a few features including byte flipping, bit flipping, bit setting and getting. The ByteObject class extends NumericObject, so math operations are possible. Creating a byte instance is done using strings rather than numbers or hex because the Copper VM does not support hex numbers.

mybyte = byte("00001101")

The full byte does not need to be given. Any number of bits less than 8 can be given, and these will set the lowest bits of the byte. The above code could have been written:

mybyte = byte("1101")

Functions are documented at the top of file cu_bytebasics.h.