Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I'm trying to construct Palindromic_number, I came up with this code:

palind[n_] := 
  FromDigits /@ Join[#, #[[All, -Mod[n, 2] - 1 ;; 1 ;; -1]], 2] &@
   Tuples[MapAt[Rest, Array[0~Range~9 &, Ceiling[n/2]], 1]];

palind[3]

(*
{101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, \
232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, \
373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, \
515, 525, 535, 545, 555, 565, 575, 585, 595, 606, 616, 626, 636, 646, \
656, 666, 676, 686, 696, 707, 717, 727, 737, 747, 757, 767, 777, 787, \
797, 808, 818, 828, 838, 848, 858, 868, 878, 888, 898, 909, 919, 929, \
939, 949, 959, 969, 979, 989, 999}
*)

Any better ideas?

share|improve this question

marked as duplicate by Simon Woods, Sjoerd C. de Vries, Artes, Silvia, Michael E2 Jun 10 '13 at 23:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Related: Functional style using lazy lists? –  Artes Jun 10 '13 at 17:10
add comment

1 Answer 1

Just for fun: using pattern matching for your 3 digit example:

Cases[IntegerDigits[Range[999]], {x_, _, x_}]

Back to WWDC :)

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.