ChatGPT has been trained on some outdated “freely available” books. I tried it with the first half of the first question of the Advent of Code 2022 and asked it to write Pharo Smalltalk.
It produced some outdated stuff using messages that are no longer there. FWIW, isOdd was present in Pharo around 2011. > On Mar 15, 2023, at 2:57 AM, Joachim Tuchel <jtuc...@objektfabrik.de> wrote: > > interesting.... > > #isOdd is not Smalltalk, neither Pharo 10 nor VAST 12 understands this > message ;-) > > If I evaluate your snippet -replacing #isOdd for #odd, I get an empty > Collection. The divisible by 4 things is somewhat interesting, because (1 to: > 100 by: 4) is amn interval 1,5,9 etc.... ;-) > > So chatGPT is probably a newbie in Smalltalk. Interesting is how logical the > explanation sounds, you're tempted to believe it... > > > > Joachim > > > > > > Am 15.03.23 um 10:45 schrieb giorgio ferraris: >> it's interesting to see how the answer changes with only a small change on >> the question: >> >> (1 to: 100 by: 4) reject: [:i | i isOdd] >> >> gives: >> The code creates a collection of numbers from 1 to 100, incrementing by 4 at >> each step using the to:by: message. It then applies the reject: message to >> this collection, which returns a new collection containing all elements for >> which the given block evaluates to false. >> >> In this case, the block is [i | i isOdd], which checks whether a given >> number i is odd using the isOdd method. So the result of the entire >> expression is a collection of all even numbers between 1 and 100 that are >> divisible by 4. >> >> >> ciao >> >> giorgio >> >> >> On Wed, Mar 15, 2023 at 8:07 AM Tim Mackinnon <tim@testit.works> >> <mailto:tim@testit.works> wrote: >>> Of course everyone is talking about ChatGPT, and I saw a post to >>> ExplainCode and didn’t expect it to understand Smalltalk, so was impressed >>> that it does! Presumably the Tonel Smalltalk code on GitHub has helped >>> along with numerous articles? >>> >>> Try it out: https://whatdoesthiscodedo.com/ >>> >>> I gave this simple example: (1 to: 100 by: 3) reject: [:i | i isOdd] >>> >>> And got this (neat eh): >>> >>> The code above is written in the programming language Smalltalk. >>> >>> It creates a collection of numbers from 1 to 100, incrementing by 3 at each >>> step. This is done using the "to:by:" construct where the starting value is >>> 1, the ending value is 100, and the increment is 3. >>> >>> The resulting collection is then filtered using the "reject:" method, which >>> takes a block of code as an argument. In this case, the block checks >>> whether each element (denoted by the variable i) is odd by using the >>> "isOdd" method. If an element is odd, it will be rejected from the >>> collection. >>> >>> So, the final result is a collection of all even numbers from 1 to 100, >>> incrementing by 3 at each step. >>> >>> Share this explanation with colleagues: whatdoesthiscodedo.com/g/a0ec56e >>> <https://whatdoesthiscodedo.com/g/a0ec56e>-- > > ----------------------------------------------------------------------- > Objektfabrik Joachim Tuchel mailto:jtuc...@objektfabrik.de > Fliederweg 1 http://www.objektfabrik.de > <http://www.objektfabrik.de/> > D-71640 Ludwigsburg http://joachimtuchel.wordpress.com > <http://joachimtuchel.wordpress.com/> > Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1 >