chatGPT writes and executes Harbour code !!!

Re: chatGPT writes and executes Harbour code !!!

Postby Jimmy » Tue Dec 20, 2022 6:17 pm

hi Silvio,
Silvio.Falconi wrote:No i must make an Array with 3element

i´m just asking as it remind me of Problem when work with "Delaunay-Triangulierung"
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Wed Dec 21, 2022 9:43 am

I need a function calc the cyclometric distance between 3 numbers , the number must b from 1 to 90 , on array of 3 element
and the distance must be equal to nvalore for esample 1


this to create the array

Code: Select all  Expand view

FUNCTION distanza_ciclometrica(nvalore)
   local aTmp := {}
   local i, j, k

   FOR i := 1 TO 90
      FOR j := i+1 TO 90
         FOR k := j+1 TO 90
            nTemp := distance(i, j, k)
            IF nTemp == nvalore
               AaDd(aTmp, {i, j, k})
            ENDIF
         NEXT
      NEXT
   NEXT
   RETURN aTmp
 


this the function calc distance

Code: Select all  Expand view
FUNCTION distance(n1, n2, n3)
   local  nMin := n1
   local  nMax := n1
   local nTemp

   IF n2 < nMin
      nMin := n2
   ENDIF
   IF n3 < nMin
      nMin := n3
   ENDIF
   IF n2 > nMax
      nMax := n2
   ENDIF
   IF n3 > nMax
      nMax := n3
   ENDIF

   nTemp := (nMax - nMin) % 90

   IF nTemp > 45
      nTemp := 90 - nTemp
   ENDIF

   RETURN nTemp




the chatGpt have made also another function But I not understood how compile it

#include "math.hbp"

FUNCTION distance(n1, n2, n3)
local nMin := math.min(n1, n2, n3)
local nMax := math.max(n1, n2, n3)

local nTemp := (nMax - nMin) % 90
nTemp := IIF(nTemp > 45, 90 - nTemp, nTemp)

RETURN nTemp
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Wed Dec 21, 2022 9:52 am

If I made
Code: Select all  Expand view
FUNCTION distanza_matematica(nvalore)
    local aTmp := {}
    local i, j, k
    FOR i := 1 TO 90
        FOR j := i+1 TO 90
           FOR k := j+1 TO 90
            If distance(i,j,k)== nvalore
             AaDd( aTmp, { i, j, k } )
                ENDIF
            NEXT
        NEXT
    NEXT
    RETURN aTmp

Function distance(n1,n2,n3)
  local nTemp:=0
            if n1>n2
               if n1>n3
                  nTemp:= n1-n2-n3
               else
                  nTemp:= n3-n1-n2
               endif
           else
              if n2>n3
                 nTemp:= n2-n1-n3
              else
                nTemp:= n3-n1-n2
             endif
           endif
         return nTemp

 


I have this result


Image


but it is wrong because it must be

1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Silvio.Falconi » Wed Dec 21, 2022 10:19 am

If I made ( load the triplets up to 10 instead 90)

Code: Select all  Expand view

FUNCTION distanza_matematica(nvalore)
    local aTmp := {}
    local nTotal,nAt
    local i, j, k
    FOR i := 1 TO 10
        FOR j := i+1 TO 10
           FOR k :=j+1  TO 10
              nTotal :=distance(i,j,k)
                  If nTotal== nvalore
                        nAt := AScan( aTmp, { |a| a[1] = k .or. a[2] = i .or.  a[3] = j  } )
                    If nAt == 0
                     AaDd( aTmp, { i, j, k } )
                    ENDIF
                  ENDIF
            NEXT
        NEXT
    NEXT
    RETURN aTmp

Function distance(n1,n2,n3)
   local nTemp:=0
            if n1>n2
               if n1>n3
                  nTemp:= n1-n2-n3
               else
                  nTemp:= n3-n1-n2
               endif
           else
              if n2>n3
                 nTemp:= n2-n1-n3
              else
                nTemp:= n3-n1-n2
             endif
           endif
         return nTemp

 



I have this result

Image



but ir wrong because must be
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10



If I change
Code: Select all  Expand view
nAt := AScan( aTmp, { |a| a[1] = i .or. a[2] = j .or.  a[3] = k  } )


the result is
Image


now the first two columns are right but the third column is wrong because it must start from number 3 and not from number 4
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: chatGPT writes and executes Harbour code !!!

Postby Jimmy » Mon Dec 26, 2022 8:20 am

ask ChatGPT
Code: Select all  Expand view
use 100 of those listed Keywords for a Christmas Story

Answer from ChatGPT
Here is a short Christmas story using 100 of the keywords from the Fivewin programming language:

It was Christmas Eve and Mary was feeling excited and anxious. She had been working on a special Christmas gift for her family using the Fivewin programming language, and she wanted to make sure everything was perfect.

She started by using the ALIAS keyword to assign a new name to the database table containing her family's gift list. Next, she used the AFIELDS keyword to retrieve the names of the fields in the table and the ADEL keyword to delete any unnecessary information.

Using the ASORT keyword, Mary sorted the list alphabetically by family member's name. She then used the ACOPY keyword to create a copy of the list as a backup.

As she worked, Mary kept an eye on the time using the ELAPTIME keyword. She didn't want to be late to the family Christmas party, so she used the ALTD keyword to check the keyboard buffer for any incoming messages from her friends or family.

As the evening approached, Mary used the CDOW keyword to check the day of the week and the DATE keyword to make sure it was indeed Christmas Eve. She then used the AMPM keyword to determine the appropriate time to leave for the party.

With everything in order, Mary packed up her computer and headed out the door. As she drove to her family's house, she used the CURDIR keyword to make sure she was headed in the right direction.

Upon arriving at the party, Mary was greeted with joy and excitement by her family. She used the ALLTRIM keyword to remove any excess space from their names as she hugged each of them.

As they sat down to dinner, Mary used the ASCAN keyword to search the table for her favorite dish. She was pleased to find that it had been included and used the AADD keyword to add an extra serving to her plate.

After dinner, the family gathered around the tree to exchange gifts. Mary used the AEVAL keyword to evaluate each gift and express her gratitude. She then used the DBCOMMIT keyword to save her appreciation in her heart and the DBUSEAREA keyword to open the database table containing her own gift for her family.

As she handed out the gifts, Mary couldn't help but feel a sense of pride and happiness. She had used the Fivewin programming language to create something special for her loved ones, and it had brought them all closer together.

As the night came to a close, Mary used the CLOSE keyword to shut down her computer and the DBCLOSEALL keyword to close the database table. She then used the AINS keyword to insert the memories of the wonderful evening into her heart and headed off to bed with a warm and contented feeling.
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: chatGPT writes and executes Harbour code !!!

Postby Antonio Linares » Mon Dec 26, 2022 8:26 am

Amazing! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 67 guests