Talk:Cyclops numbers

From Rosetta Code

Don't forget that '0' is a Cyclops number[edit]

It has an odd number of digits (namely 1) and it's middle (and only) digit is '0'.

It's also classified as such in OEIS A134808 - Cyclops numbers. --PureFox (talk) 09:22, 24 June 2021 (UTC)

Indeed you are correct. Thanks. --Thundergnat (talk) 10:19, 24 June 2021 (UTC)

Nice recursive solution[edit]

The cartesian product cP N G, where N and G are lists of integers, returns a list of tuples (n,g) where n and g are all the members of N and G ordered by n then g. If digits is the list of integers from 1 to 9 then I can define cyclops r s where r is initialized to 100 and s to digits as follows:

 for n in cP s s output r*n+g
 cyclops (r*10) (cP s digits mapped to 10*n+g)
Not entirely unlike what bump(half) in the Phix entry does, but then I use left and right to manually step through the product. I guess it could have been clearer if only I had used P(L) and p and l as my "identifiers", when I read the above I cannot help but be reminded of this classic cartoon. --Pete Lomax (talk) 17:45, 28 June 2021 (UTC)
Joking apart do you really want me to compare the Phix entry with the nice recursive, and entirely functional, solution outlined above? There are mutable flags tested with if statements nested four deep. RC's Cartesian product task has a Phix entry which is almost functional, why not use it? I've only just read the Phix entry since you've drawn my attention to it, when I wrote this I was thinking of the Factor entry which follows F# so I couldn't help seeing it. I believe Cartesian product and even Cartesian product map are built in functions of Factor!--Nigel Galloway (talk) 14:37, 29 June 2021 (UTC)
Oh, abso-****ing-lutely, bring it on and aggressive feints be damned. This is what this site is (actually) for.
For once I get we are talking about the exact same algorithm and both will/should defend our positions to the hilt. Don your thickest hide, I will do the same.
I guess I simply don't get the functional approach that you/Factor/Hout are on about (but unlike Paddy3118 I'd rather learn than delete).
I just don't get how you "grok" that code, or (more importantly) how you can ever possibly debug or modify it.
I'll not deny "nested four deep" or "mutable flags" but (of course) simply don't get why either is an issue.
I do of course pick up little bits from here and there, I guess just don't get "the bigger picture".
I do now understand the Factor entry much better (many thanks) but several details are still far from clear to me, for instance what is "9199 -- 9211" up to?
The lack of sensible names troubles me, and (eg) "let N, i, g, e, l =" just strikes me as utterly ridiculous. --Pete Lomax (talk) 03:26, 30 June 2021 (UTC)