--- Begin Message ---Op 2-5-2020 om 21:09 schreef Roelof Wobben via Pharo-users:but this seems to work : cardNumber := '4539 1488 0343 6467'. cleanDigits := cardNumber copyWithout: Character space.preWrapDigits := (cleanDigits asArray reverse collectWithIndex: [ :char :idx | (idx even) ifTrue: [ 2 * char digitValue ] ifFalse:[char digitValue]]). wrappedDigits := preWrapDigits collect: [ :d | d > 9 ifFalse: [ d ] ifTrue: [ d-9 ] ].^ wrappedDigits sum isDivisibleBy: 10. Can the code be more improved ? Roelof
--- End Message ---
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Richard Sargent
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Richard O'Keefe
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Richard Sargent
- Re: [Pharo-users] mentor question 4 Ben Coman
- Re: [Pharo-users] mentor questi... Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor qu... Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor qu... Richard Sargent
- Re: [Pharo-users] mentor qu... Stéphane Ducasse
- Re: [Pharo-users] mentor questi... Ben Coman
- Re: [Pharo-users] mentor qu... Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor qu... Ben Coman
- Re: [Pharo-users] mentor qu... Roelof Wobben via Pharo-users
- Re: [Pharo-users] mentor question 4 Trygve Reenskaug
- Re: [Pharo-users] mentor questi... Richard O'Keefe
- Re: [Pharo-users] mentor qu... Richard O'Keefe
- Re: [Pharo-users] mentor qu... Stéphane Ducasse