[Pharo-users] order of execution
Can someone please explain this? I'm guessing I don't understand order of execution. When perusing >>fibonacciSequence, I get a proper result, but I don't understand why when looking at the code. Consider this fragment... prevTotal := 0. currTotal := 1. currTotal := prevTotal + (prevTotal := currTotal). My understanding *was* that parentheses are executed first. (prevTotal := currTotal) - assigns and returns 1 currTotal := prevTotal + (1) and since prevTotal = 1 currTotal := 1 + (1) prevTotal = 1. currTotal = 2. Yet what appears to be happening is... prevTotal = 0 currTotal := 0 + (prevTotal := currTotal) then the parentheses... currTotal := 0 + (1) prevTotal = 1. currTotal = 1. Care to school me? Thanks! Russ -- Russ Whaley whaley.r...@gmail.com
[Pharo-users] Re: roman numbers
Op 18-9-2020 om 06:45 schreef Richard O'Keefe: Roman numerals are much more complicated and much less consistent than most people realise. The regular M DC LX VI system is both more modern and less capable than anything the Romans would have recognised. In particular, - in the 8th century, N (short for "nulla") was adopted for zero - the Roman system always had fractions like S for 1/2, . for 1/12 - there were numerals for much larger numbers. Unicode code block [2150] has characters for the Roman numerals including 216C L ROMAN NUMERAL FIFTY 216D C ROMAN NUMERAL ONE HUNDRED 216E D ROMAN NUMERAL FIVE HUNDRED 216F M ROMAN NUMERAL ONE THOUSAND 2181 ↁ ROMAN NUMERAL FIVE THOUSAND 2182 ↂ ROMAN NUMERAL TEN THOUSAND 2187 ↇ ROMAN NUMERAL FIFTY THOUSAND 2188 ↈ ROMAN NUMERAL ONE HUNDRED THOUSAND (In fact these are ligated versions of forms using "apostrophic" brackets; the pattern goes as high as you want, e.g., (((|))) for a million. D and M were originally |) and (|). There is So the first thing is to make sure that you understand the requirements for the problem. - Are you required to produce ASCII characters, required to produce Unicode ones, or allowed to produce either? as far as I can see from the tests only ASCI characters. - Are you required to support zero? No - Are you required to support n/12 fractions (1<=n<=11)? NO - Are you allowed, required, or forbidden to use the "overline" convention, where an overline means "multiply by 1000"? =--- In the test that one is not used. ICCXXXIVDLXVII = 1,234,567 - Are you allowed, required, or forbidden to use "additive" form "" as well as/instead of "subtractive" form "IV"? - Are you to use upper case or lower case letters? - And so on. the number 4 needs to be "IV" Roelof
[Pharo-users] Re: roman numbers
Hi! Maybe you can use this algorithm: Define a dictionary with these elements: 1000:'M', 900:'CM', 500: 'D', 400: 'CD', 100:"C", 90:'XC', 50:'L', 40:'XL', 10:'X', 9:'IX', 5:'V', 4:'IV', 1:'I' Using this dictionary (romansDic), you define a recursive function: toRomans(number){ i = return the greatest key less than or equal to given key from ‘romansDic' . if (number == i ){ return romansDic.get(number) } return string_concat(romansDic.get(i), toRomans(number-i)) } Sorry for the pseudocode. Saludos Pablo. El 18 de sep. de 2020 10:46 -0300, Roelof Wobben via Pharo-users , escribió: > Op 18-9-2020 om 06:45 schreef Richard O'Keefe: > > Roman numerals are much more complicated and much less consistent > > than most people realise. The regular M DC LX VI system is both > > more modern and less capable than anything the Romans would have > > recognised. In particular, > > - in the 8th century, N (short for "nulla") was adopted for zero > > - the Roman system always had fractions like S for 1/2, . for 1/12 > > - there were numerals for much larger numbers. > > Unicode code block [2150] has characters for the Roman numerals > > including > > 216C L ROMAN NUMERAL FIFTY > > 216D C ROMAN NUMERAL ONE HUNDRED > > 216E D ROMAN NUMERAL FIVE HUNDRED > > 216F M ROMAN NUMERAL ONE THOUSAND > > 2181 ↁ ROMAN NUMERAL FIVE THOUSAND > > 2182 ↂ ROMAN NUMERAL TEN THOUSAND > > 2187 ↇ ROMAN NUMERAL FIFTY THOUSAND > > 2188 ↈ ROMAN NUMERAL ONE HUNDRED THOUSAND > > (In fact these are ligated versions of forms using "apostrophic" brackets; > > the pattern goes as high as you want, e.g., (((|))) for a million. > > D and M were originally |) and (|). There is > > > > So the first thing is to make sure that you understand the > > requirements for the problem. > > - Are you required to produce ASCII characters, required to > > produce Unicode ones, or allowed to produce either? > > as far as I can see from the tests only ASCI characters. > > > - Are you required to support zero? > > No > > > - Are you required to support n/12 fractions (1<=n<=11)? > > NO > > > - Are you allowed, required, or forbidden to use the "overline" > > convention, where an overline means "multiply by 1000"? > > =--- > > In the test that one is not used. > > ICCXXXIVDLXVII = 1,234,567 > > - Are you allowed, required, or forbidden to use "additive" > > form "" as well as/instead of "subtractive" form "IV"? > > - Are you to use upper case or lower case letters? > > - And so on. > > > > > > > the number 4 needs to be "IV" > > Roelof >
[Pharo-users] Re: order of execution
Hi, don't forget to read the expression from left to right: currTotal := prevTotal + (prevTotal := currTotal). 5 1 43 2 1. the current value (X) of prevTotal is fetched. 2. the current value (Y) of currTotal is fetched 3. prevTotal is assigned currTotal which is also the value of the parenthesis 4. X is sent the message + with the argument Y 5. currTotal is assigned the result from 4. Kind regards, Steffen Am .09.2020, 15:05 Uhr, schrieb Russ Whaley : Can someone please explain this? I'm guessing I don't understand order of execution. When perusing >>fibonacciSequence, I get a proper result, but I don't understand why when looking at the code. Consider this fragment... prevTotal := 0. currTotal := 1. currTotal := prevTotal + (prevTotal := currTotal). My understanding *was* that parentheses are executed first. (prevTotal := currTotal) - assigns and returns 1 currTotal := prevTotal + (1) and since prevTotal = 1 currTotal := 1 + (1) prevTotal = 1. currTotal = 2. Yet what appears to be happening is... prevTotal = 0 currTotal := 0 + (prevTotal := currTotal) then the parentheses... currTotal := 0 + (1) prevTotal = 1. currTotal = 1. Care to school me? Thanks! Russ
[Pharo-users] Re: roman numbers
Op 18-9-2020 om 16:13 schreef Pablo Navarro: Hi! Maybe you can use this algorithm: Define a dictionary with these elements: 1000:'M', 900:'CM', 500: 'D', 400: 'CD', 100:"C", 90:'XC', 50:'L', 40:'XL', 10:'X', 9:'IX', 5:'V', 4:'IV', 1:'I' Using this dictionary (romansDic), you define a recursive function: toRomans(number){ i = return the greatest key less than or equal to given key from ‘romansDic' . if (number == i ){ return romansDic.get(number) } return string_concat(romansDic.get(i), toRomans(number-i)) } Sorry for the pseudocode. Saludos Pablo. No problem. I searching for a idea not somebody who solves it for me. Roelof
[Pharo-users] AthensCairoSDLSurface P8 Error
Hello, This code that worked for P6 and P7 is now failing in P8. *AthensCairoSDLSurface fromSDLSurface: self window handle handle getWindowSurface.* the window is created like this: *window := OSWindow createWithAttributes: (OSWindowAttributes new resizable: false; yourself).* The exception is Error: Could not coerce arguments from cairo lib. Cheers
[Pharo-users] Telegram Bots with Pharo
Hi everyone, I share a tool for creating telegram Bots with Pharo. This library provides an interface for the Telegram Bot API. To create our telegram bot in Pharo, the first thing we need to do is to create a new object that inherits from Bottlegram. This object must define at least these three methods: • slashStart: to be executed when the bot receives /start. • slashHelp: to be executed when the bot receives /help. • defaultText: to be executed when the bot receives an unknown command. The tool allows creating bots using two methods: • Using polling: the bot check updates for an amount of time. • Using webhook: Use this method to create a Teapot server to receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we received an HTTPS POST request to the specified URL Github link: https://github.com/pablo1n7/bottlegram If you use Telegram, do you test an echo bot in https://t.me/echo_pharo_bot Saludos, Pablo.
[Pharo-users] Re: CV/OCR Library
Esteban A. Maringolo wrote > Thanks for the reference. I'll look into it! >> I know that Sean D has wrapped the Tesseract OCR library: >> https://github.com/seandenigris/Tesseract-St Esteban, I did a little work getting it working in Pharo 8 and adding an example. Check out `Tesseract class>>#exampleHOCR` and LMK if it fits your needs. If not, PRs are welcome ;-) FYI I'm developing in Gtoolkit at the moment, so I'm not sure if the Morphic part (e.g. inspector extensions) still works, but I think it should. What's been implemented so far in the Bloc equivalent works in latest GT, but is WIP. - Cheers, Sean -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html