On Apr 1, 2023, at 08:08, Branimir Maksimovic <branimir.maksimovic@gmail.com> wrote:
Of course it’ useless. GPT should be tested with something that can’t be foundon internet :PI tried with problem euler 512, it can’t find optimal solution, but can performmicrooptimisations of existing solution, which is still impressive :PGreets, Branimir._______________________________________________On 1. 4. 2023., at 01:01, Alexey Vagarenko <vagarenko@gmail.com> wrote:Isn’t binary search useless for lists? It performs worse than full list traversal._______________________________________________Сб, 1 апр. 2023 г. в 03:43, Branimir Maksimovic <branimir.maksimovic@gmail.com>:I was thoughtt from my mathematic logic proffesor in 1987 that algorithm for making algorithmsdoesn’t exist. He proved that there is no algorihm for provin hieor order logic formulas…Greets, Branmir._______________________________________________On 31. 3. 2023., at 23:37, Yasuaki Kudo <yasu@yasuaki.com> wrote:_______________________________________________I am really curious - is it possible to create a programming language designed from the ground up to be used by GPT and similar tools?- Easy to specify the desired outcome- Easy to verify resultsI tried GPT4 to produce COQ proofs of Yoneda Lemma but it could not even complete the interfaces (without implementation) - they failed to compile, by being tripped up by implicit parameters etc.But GPT4 gets much closer to completion compared to GPT3.5I wonder what "GPT-native" programming language might look like😄-YasuOn Apr 1, 2023, at 06:24, Levent Erkok <erkokl@gmail.com> wrote:This code is buggy when lo + hi overflows your integer type. Classic (extremely) corner case bug: https://ai.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.htmlOn Mar 31, 2023, at 1:02 PM, Gregory Guthrie <guthrie@miu.edu> wrote:_______________________________________________From a colleague:GPT Pretty smart(?!).But this is of course simple, and searchable.Still…--------------------------------------------------------------------------------------------------GPT-4 when prompted:
Write binary search in Haskel. Print results using putStrLn. Ensure bug-free code by specifying preconditions, postconditions, invariants, variants, internal states.gives the following response:
-- Binary search in Haskell
-- Precondition: the list is sorted in ascending order
-- Postcondition: the function returns the index of the target element if found, or Nothing otherwise
-- Invariant: the search space is always within the bounds of the list
-- Variant: the search space decreases by half at each recursive call
-- Internal state: the lower and upper bounds of the search space
binarySearch :: Ord a => [a] -> a -> Maybe Int
binarySearch xs x = go xs x 0 (length xs - 1)
where
go xs x lo hi
| lo > hi = Nothing -- base case: search space is empty
| x == midElem = Just mid -- base case: target element is found
| x < midElem = go xs x lo (mid - 1) -- recursive case: search in the left half
| otherwise = go xs x (mid + 1) hi -- recursive case: search in the right half
where
mid = (lo + hi) `div` 2 -- calculate the middle index
midElem = xs !! mid -- get the middle element
-- Print results using putStrLn
main :: IO ()
main = do
let xs = [1, 3, 5, 7, 9] -- a sorted list of integers
let x = 5 -- a target element to search for
let result = binarySearch xs x -- call the binary search function
case result of -- pattern match on the result
Nothing -> putStrLn "Element not found" -- print a message if Nothing is returned
Just i -> putStrLn $ "Element found at index " ++ show i -- print a message with the index if Just i is returnedThe above code runs:
<image001.png>
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.