Talk:Cyclops numbers

From Rosetta Code

Don't forget that '0' is a Cyclops number

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

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)