DeepSeek and Xojo... interesting

Took DeepSeek - the chinese AI company which you probably heard off, which is crashing the big AI tech stock at the moment - for a spin using questions on and classic AI tests, for Xojo.

  • I made it write a nice tetris game in one go
  • Snake game
  • Custom control using a canvas.
  • and provide a few solutions using external methods on Mac OS and Windows.

Everything ran in first go… really impressive and the story behind the model is very interesting.

4 Likes

Ask if xojo has an array reverse sort.

1 Like

Ask sort a point array by point distance.

how about add a hi-score to the tetris game visible in web.

From DeepSeek:

As of my knowledge cutoff in July 2024, Xojo does not have a built-in method to reverse an array. You would need to implement your own method, such as the one I provided earlier, to reverse an array.

However, Xojo does provide some array manipulation methods, such as Sort, Insert, Remove, and Append, but reversing an array is not one of the built-in functionalities. If this has changed in a newer version of Xojo, I recommend checking the official Xojo documentation for updates.

If you frequently need to reverse arrays, you could encapsulate the logic into a reusable method or extend the array functionality using a module or class. Here’s an example of how you could create a reusable method in a module:

Module: ArrayUtilities

Module ArrayUtilities
  Sub ReverseArray(Array() As Variant)
    Dim lowIndex As Integer = 0
    Dim highIndex As Integer = Array.Ubound
    
    While lowIndex < highIndex
      ' Swap the elements
      Dim temp As Variant = Array(lowIndex)
      Array(lowIndex) = Array(highIndex)
      Array(highIndex) = temp
      
      ' Move towards the center
      lowIndex = lowIndex + 1
      highIndex = highIndex - 1
    Wend
  End Sub
End Module

Usage:

Dim myArray() As String = ["Apple", "Banana", "Cherry", "Date"]
ArrayUtilities.ReverseArray(myArray)

' myArray will now be ["Date", "Cherry", "Banana", "Apple"]

This approach keeps your code clean and reusable. If Xojo adds a built-in method for reversing arrays in the future, you can easily update your code to use the native functionality.

1 Like

It’s factually correct about not having a reverse, but that code won’t work, and even if corrected, would only work for the very specific array of variants and not for other array types.

2 Likes

instead of reverse an array i would iterate backwards, no need to swap data.

For i As Integer = data.LastIndex DownTo data.FirstIndex 
Next

Xojo can use a compare method Sort(AddressOf methodName)
basically for the content but could also be a class with few properties.

3 Likes

lol I read this plagiarism machine is being investigated for plagiarizing the existing plagiarism machines, and the existing plagiarism machines are all boohoo about having their work stolen.

17 Likes

This is the Quicksort routine which is slow. You should better use Shellsort which is much faster.

It’s worthwhile to read about different sort techniques (Wikipedia) to see which one most closely matches the initial state and number of elements you expect to have.

Here’s bit on using the best Gap in the Shell Sort:


Regarding the best gap sequence, the choice of gap sequence is crucial to shell sort’s performance. A gap sequence determines how far elements are sorted apart from each other and directly affects the efficiency of the sorting process.

Some popular gap sequences include:

  1. Shell’s Original Sequence: Halving the number of elements each time (N/2, N/4, ..., 1). This sequence is easy to implement but not the most efficient.

  2. Hibbard’s Sequence: Powers of two minus one (1, 3, 7, 15, ...). This tends to perform better than Shell’s original sequence.

  3. Knuth’s Sequence: Formula is 1, 4, 13, 40, ... which is h = 3h + 1. It often performs better in practical use.

  4. Sedgewick’s Sequences: These are more complex sequences designed for superior performance in practice, especially for larger arrays.

  5. Ciura’s Sequence: An empirically derived sequence (1, 4, 10, 23, 57, 132, 301, 701, 1750). This sequence has been shown to produce efficient results for practical problems.