From westerman at purdue.edu Tue Jan 12 11:18:12 2010 From: westerman at purdue.edu (Rick Westerman) Date: Tue, 12 Jan 2010 14:18:12 -0500 Subject: [Purdue-pm] Meeting in one week Message-ID: <4B4CCAF4.4000101@purdue.edu> Reminder that our meeting is in one week on Tuesday, Jan 19th. From noon to 1. Social time is from 11:30 to noon. Same WSLR 116. At the moment we have the following scheduled Mark might do a short Perl 5 elseif talk Mark is thinking of presenting on Perl 6. I am am doing a "rewind" talk (i.e., one that I did before, 2 years ago) on the proposed 'switch statement' And for everyone, Mark's short programming problem on taking the ASCII character code and outputting it into a desired format. My solution is 2 lines (statements) long (not counting the 2 I/O statements) and like Mark's solution does not include any explicit chr, do, for, if, ord, sub, while or until. It will interesting to see what Mark and the rest of you come up with. -- Rick Westerman westerman at purdue.edu Bioinformatics specialist at the Genomics Facility. Phone: (765) 494-0505 FAX: (765) 496-7255 Department of Horticulture and Landscape Architecture 625 Agriculture Mall Drive West Lafayette, IN 47907-2010 Physically located in room S049, WSLR building From pmiguel at purdue.edu Tue Jan 12 12:51:24 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Tue, 12 Jan 2010 15:51:24 -0500 Subject: [Purdue-pm] Perl 5 programming challenge In-Reply-To: <9622.1262890330@pier.ecn.purdue.edu> References: <9622.1262890330@pier.ecn.purdue.edu> Message-ID: <4B4CE0CC.30201@purdue.edu> Mark Senn wrote: > I came across the following when doing normal work for my job. > > Using the following > ==== start with next line > 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL > 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI > 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB > 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US > 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' > 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / > 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 > 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? > 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G > 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O > 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W > 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ > 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g > 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o > 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w > 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 DEL > ==== end with previous line > in a here document set up an array @print in Perl 5 so that elements > 0..31 are '.' > 32 is ' ' > 33..126 are as listed > 127 is '.' > 128..255 is '.' > > I'll show my solution (that doesn't use chr, do, for, if, ord, sub, > while, until) at next meeting and would like to see other solutions with > or without the parenthesized restraint above. -mark > > To which Rick bragged: > My solution is 2 lines (statements) long (not counting the 2 I/O > statements) and like Mark's solution does not include any explicit > chr, do, for, if, ord, sub, while or until. It will interesting to > see what Mark and the rest of you come up with. I demand to see a use Data::Dumper; print Dumper \@here; of your @here! I can't get below3 statements other than the heredoc assignment of Mark's string to $_. But I don't use grep or map. Phillip From westerman at purdue.edu Tue Jan 12 13:09:23 2010 From: westerman at purdue.edu (Rick Westerman) Date: Tue, 12 Jan 2010 16:09:23 -0500 Subject: [Purdue-pm] Perl 5 programming challenge In-Reply-To: <4B4CE0CC.30201@purdue.edu> References: <9622.1262890330@pier.ecn.purdue.edu> <4B4CE0CC.30201@purdue.edu> Message-ID: <4B4CE503.20503@purdue.edu> > To which Rick bragged: > >> My solution is 2 lines (statements) long (not counting the 2 I/O >> statements) and like Mark's solution does not include any explicit >> chr, do, for, if, ord, sub, while or until. It will interesting to >> see what Mark and the rest of you come up with. > I demand to see a > > > use Data::Dumper; > print Dumper \@here; > > > of your @here! > > What, you want me to give away my secrets? :-) People *really* need to come to the Mongers meeting if they want to see them. Never-the-less, below is is Dumper of the @here followed by a Dumper of my @print. Yes, the @here is not perfectly parsed but as I noted in my code this doesn't matter since the first and last elements will be overwritten. And, no, I don't use 'grep' nor 'map'. $VAR1 = '0 NUL'; $VAR2 = 'SOH'; $VAR3 = 'STX'; $VAR4 = 'ETX'; $VAR5 = 'EOT'; $VAR6 = 'ENQ'; $VAR7 = 'ACK'; $VAR8 = 'BEL'; $VAR9 = 'BS'; $VAR10 = 'HT'; $VAR11 = 'NL'; $VAR12 = 'VT'; $VAR13 = 'NP'; $VAR14 = 'CR'; $VAR15 = 'SO'; $VAR16 = 'SI'; $VAR17 = 'DLE'; $VAR18 = 'DC1'; $VAR19 = 'DC2'; $VAR20 = 'DC3'; $VAR21 = 'DC4'; $VAR22 = 'NAK'; $VAR23 = 'SYN'; $VAR24 = 'ETB'; $VAR25 = 'CAN'; $VAR26 = 'EM'; $VAR27 = 'SUB'; $VAR28 = 'ESC'; $VAR29 = 'FS'; $VAR30 = 'GS'; $VAR31 = 'RS'; $VAR32 = 'US'; $VAR33 = 'SP'; $VAR34 = '!'; $VAR35 = '"'; $VAR36 = '#'; $VAR37 = '$'; $VAR38 = '%'; $VAR39 = '&'; $VAR40 = '\''; $VAR41 = '('; $VAR42 = ')'; $VAR43 = '*'; $VAR44 = '+'; $VAR45 = ','; $VAR46 = '-'; $VAR47 = '.'; $VAR48 = '/'; $VAR49 = '0'; $VAR50 = '1'; $VAR51 = '2'; $VAR52 = '3'; $VAR53 = '4'; $VAR54 = '5'; $VAR55 = '6'; $VAR56 = '7'; $VAR57 = '8'; $VAR58 = '9'; $VAR59 = ':'; $VAR60 = ';'; $VAR61 = '<'; $VAR62 = '='; $VAR63 = '>'; $VAR64 = '?'; $VAR65 = '@'; $VAR66 = 'A'; $VAR67 = 'B'; $VAR68 = 'C'; $VAR69 = 'D'; $VAR70 = 'E'; $VAR71 = 'F'; $VAR72 = 'G'; $VAR73 = 'H'; $VAR74 = 'I'; $VAR75 = 'J'; $VAR76 = 'K'; $VAR77 = 'L'; $VAR78 = 'M'; $VAR79 = 'N'; $VAR80 = 'O'; $VAR81 = 'P'; $VAR82 = 'Q'; $VAR83 = 'R'; $VAR84 = 'S'; $VAR85 = 'T'; $VAR86 = 'U'; $VAR87 = 'V'; $VAR88 = 'W'; $VAR89 = 'X'; $VAR90 = 'Y'; $VAR91 = 'Z'; $VAR92 = '['; $VAR93 = '\\'; $VAR94 = ']'; $VAR95 = '^'; $VAR96 = '_'; $VAR97 = '`'; $VAR98 = 'a'; $VAR99 = 'b'; $VAR100 = 'c'; $VAR101 = 'd'; $VAR102 = 'e'; $VAR103 = 'f'; $VAR104 = 'g'; $VAR105 = 'h'; $VAR106 = 'i'; $VAR107 = 'j'; $VAR108 = 'k'; $VAR109 = 'l'; $VAR110 = 'm'; $VAR111 = 'n'; $VAR112 = 'o'; $VAR113 = 'p'; $VAR114 = 'q'; $VAR115 = 'r'; $VAR116 = 's'; $VAR117 = 't'; $VAR118 = 'u'; $VAR119 = 'v'; $VAR120 = 'w'; $VAR121 = 'x'; $VAR122 = 'y'; $VAR123 = 'z'; $VAR124 = '{'; $VAR125 = '|'; $VAR126 = '}'; $VAR127 = '~'; $VAR128 = 'DEL '; $VAR1 = '.'; $VAR2 = '.'; $VAR3 = '.'; $VAR4 = '.'; $VAR5 = '.'; $VAR6 = '.'; $VAR7 = '.'; $VAR8 = '.'; $VAR9 = '.'; $VAR10 = '.'; $VAR11 = '.'; $VAR12 = '.'; $VAR13 = '.'; $VAR14 = '.'; $VAR15 = '.'; $VAR16 = '.'; $VAR17 = '.'; $VAR18 = '.'; $VAR19 = '.'; $VAR20 = '.'; $VAR21 = '.'; $VAR22 = '.'; $VAR23 = '.'; $VAR24 = '.'; $VAR25 = '.'; $VAR26 = '.'; $VAR27 = '.'; $VAR28 = '.'; $VAR29 = '.'; $VAR30 = '.'; $VAR31 = '.'; $VAR32 = '.'; $VAR33 = ' '; $VAR34 = '!'; $VAR35 = '"'; $VAR36 = '#'; $VAR37 = '$'; $VAR38 = '%'; $VAR39 = '&'; $VAR40 = '\''; $VAR41 = '('; $VAR42 = ')'; $VAR43 = '*'; $VAR44 = '+'; $VAR45 = ','; $VAR46 = '-'; $VAR47 = '.'; $VAR48 = '/'; $VAR49 = '0'; $VAR50 = '1'; $VAR51 = '2'; $VAR52 = '3'; $VAR53 = '4'; $VAR54 = '5'; $VAR55 = '6'; $VAR56 = '7'; $VAR57 = '8'; $VAR58 = '9'; $VAR59 = ':'; $VAR60 = ';'; $VAR61 = '<'; $VAR62 = '='; $VAR63 = '>'; $VAR64 = '?'; $VAR65 = '@'; $VAR66 = 'A'; $VAR67 = 'B'; $VAR68 = 'C'; $VAR69 = 'D'; $VAR70 = 'E'; $VAR71 = 'F'; $VAR72 = 'G'; $VAR73 = 'H'; $VAR74 = 'I'; $VAR75 = 'J'; $VAR76 = 'K'; $VAR77 = 'L'; $VAR78 = 'M'; $VAR79 = 'N'; $VAR80 = 'O'; $VAR81 = 'P'; $VAR82 = 'Q'; $VAR83 = 'R'; $VAR84 = 'S'; $VAR85 = 'T'; $VAR86 = 'U'; $VAR87 = 'V'; $VAR88 = 'W'; $VAR89 = 'X'; $VAR90 = 'Y'; $VAR91 = 'Z'; $VAR92 = '['; $VAR93 = '\\'; $VAR94 = ']'; $VAR95 = '^'; $VAR96 = '_'; $VAR97 = '`'; $VAR98 = 'a'; $VAR99 = 'b'; $VAR100 = 'c'; $VAR101 = 'd'; $VAR102 = 'e'; $VAR103 = 'f'; $VAR104 = 'g'; $VAR105 = 'h'; $VAR106 = 'i'; $VAR107 = 'j'; $VAR108 = 'k'; $VAR109 = 'l'; $VAR110 = 'm'; $VAR111 = 'n'; $VAR112 = 'o'; $VAR113 = 'p'; $VAR114 = 'q'; $VAR115 = 'r'; $VAR116 = 's'; $VAR117 = 't'; $VAR118 = 'u'; $VAR119 = 'v'; $VAR120 = 'w'; $VAR121 = 'x'; $VAR122 = 'y'; $VAR123 = 'z'; $VAR124 = '{'; $VAR125 = '|'; $VAR126 = '}'; $VAR127 = '~'; $VAR128 = '.'; $VAR129 = '.'; $VAR130 = '.'; $VAR131 = '.'; $VAR132 = '.'; $VAR133 = '.'; $VAR134 = '.'; $VAR135 = '.'; $VAR136 = '.'; $VAR137 = '.'; $VAR138 = '.'; $VAR139 = '.'; $VAR140 = '.'; $VAR141 = '.'; $VAR142 = '.'; $VAR143 = '.'; $VAR144 = '.'; $VAR145 = '.'; $VAR146 = '.'; $VAR147 = '.'; $VAR148 = '.'; $VAR149 = '.'; $VAR150 = '.'; $VAR151 = '.'; $VAR152 = '.'; $VAR153 = '.'; $VAR154 = '.'; $VAR155 = '.'; $VAR156 = '.'; $VAR157 = '.'; $VAR158 = '.'; $VAR159 = '.'; $VAR160 = '.'; $VAR161 = '.'; $VAR162 = '.'; $VAR163 = '.'; $VAR164 = '.'; $VAR165 = '.'; $VAR166 = '.'; $VAR167 = '.'; $VAR168 = '.'; $VAR169 = '.'; $VAR170 = '.'; $VAR171 = '.'; $VAR172 = '.'; $VAR173 = '.'; $VAR174 = '.'; $VAR175 = '.'; $VAR176 = '.'; $VAR177 = '.'; $VAR178 = '.'; $VAR179 = '.'; $VAR180 = '.'; $VAR181 = '.'; $VAR182 = '.'; $VAR183 = '.'; $VAR184 = '.'; $VAR185 = '.'; $VAR186 = '.'; $VAR187 = '.'; $VAR188 = '.'; $VAR189 = '.'; $VAR190 = '.'; $VAR191 = '.'; $VAR192 = '.'; $VAR193 = '.'; $VAR194 = '.'; $VAR195 = '.'; $VAR196 = '.'; $VAR197 = '.'; $VAR198 = '.'; $VAR199 = '.'; $VAR200 = '.'; $VAR201 = '.'; $VAR202 = '.'; $VAR203 = '.'; $VAR204 = '.'; $VAR205 = '.'; $VAR206 = '.'; $VAR207 = '.'; $VAR208 = '.'; $VAR209 = '.'; $VAR210 = '.'; $VAR211 = '.'; $VAR212 = '.'; $VAR213 = '.'; $VAR214 = '.'; $VAR215 = '.'; $VAR216 = '.'; $VAR217 = '.'; $VAR218 = '.'; $VAR219 = '.'; $VAR220 = '.'; $VAR221 = '.'; $VAR222 = '.'; $VAR223 = '.'; $VAR224 = '.'; $VAR225 = '.'; $VAR226 = '.'; $VAR227 = '.'; $VAR228 = '.'; $VAR229 = '.'; $VAR230 = '.'; $VAR231 = '.'; $VAR232 = '.'; $VAR233 = '.'; $VAR234 = '.'; $VAR235 = '.'; $VAR236 = '.'; $VAR237 = '.'; $VAR238 = '.'; $VAR239 = '.'; $VAR240 = '.'; $VAR241 = '.'; $VAR242 = '.'; $VAR243 = '.'; $VAR244 = '.'; $VAR245 = '.'; $VAR246 = '.'; $VAR247 = '.'; $VAR248 = '.'; $VAR249 = '.'; $VAR250 = '.'; $VAR251 = '.'; $VAR252 = '.'; $VAR253 = '.'; $VAR254 = '.'; $VAR255 = '.'; $VAR256 = '.'; -- Rick Westerman westerman at purdue.edu Bioinformatics specialist at the Genomics Facility. Phone: (765) 494-0505 FAX: (765) 496-7255 Department of Horticulture and Landscape Architecture 625 Agriculture Mall Drive West Lafayette, IN 47907-2010 Physically located in room S049, WSLR building From westerman at purdue.edu Wed Jan 13 06:13:21 2010 From: westerman at purdue.edu (Rick Westerman) Date: Wed, 13 Jan 2010 09:13:21 -0500 Subject: [Purdue-pm] More on Mark's challenge Message-ID: <4B4DD501.7030405@purdue.edu> I had a question today as to if is required to use the 'hereis' text Mark put in his original challenge email. My feeling is 'yes'. Just filling up an array with serial ASCII characters defeats part of the challenge -- one could certainly imagine a scenario where arbitrary text is used in a non-serial manner. But maybe I am saying this because working with the 'hereis' took most of my less than 2 hour effort (I almost never use 'hereis') and so want to see what other people come up with. I am looking forward to Tuesday to see what people come up with. TIMTOWTDI !!! -- Rick Westerman westerman at purdue.edu Bioinformatics specialist at the Genomics Facility. Phone: (765) 494-0505 FAX: (765) 496-7255 Department of Horticulture and Landscape Architecture 625 Agriculture Mall Drive West Lafayette, IN 47907-2010 Physically located in room S049, WSLR building From pmiguel at purdue.edu Wed Jan 13 06:47:11 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Wed, 13 Jan 2010 09:47:11 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <4B4DD501.7030405@purdue.edu> References: <4B4DD501.7030405@purdue.edu> Message-ID: <4B4DDCEF.5000405@purdue.edu> Rick Westerman wrote: > I had a question today as to if is required to use the 'hereis' text > Mark put in his original challenge email. My feeling is 'yes'. Just > filling up an array with serial ASCII characters defeats part of the > challenge -- one could certainly imagine a scenario where arbitrary > text is used in a non-serial manner. But maybe I am saying this > because working with the 'hereis' took most of my less than 2 hour > effort (I almost never use 'hereis') and so want to see what other > people come up with. > > I am looking forward to Tuesday to see what people come up with. > TIMTOWTDI !!! > Rick, The term is not "hereis", it is a here document or "heredoc". See: http://en.wikipedia.org/wiki/Heredoc I believe Mark's intent is that the string initially be loaded with the block of text he gave in the email and that code be written to convert that block of text into the array he describes. The code to load that block of text into a variable using a heredoc, I presume, was meant by Mark to be trivial, not really part of the challange: $_ =<<'END'; 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 DEL END Or did I misinterpret you Mark? Phillip From westerman at purdue.edu Wed Jan 13 07:14:05 2010 From: westerman at purdue.edu (Rick Westerman) Date: Wed, 13 Jan 2010 10:14:05 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <4B4DDCEF.5000405@purdue.edu> References: <4B4DD501.7030405@purdue.edu> <4B4DDCEF.5000405@purdue.edu> Message-ID: <4B4DE33D.4010403@purdue.edu> Phillip San Miguel wrote: > > Rick Westerman wrote: >> I had a question today as to if is required to use the 'hereis' >> text Mark put in his original challenge email. My feeling is >> 'yes'. Just filling up an array with serial ASCII characters >> defeats part of the challenge -- one could certainly imagine a >> scenario where arbitrary text is used in a non-serial manner. But >> maybe I am saying this because working with the 'hereis' took most of >> my less than 2 hour effort (I almost never use 'hereis') and so want >> to see what other people come up with. >> >> I am looking forward to Tuesday to see what people come up with. >> TIMTOWTDI !!! >> > > Rick, > The term is not "hereis", it is a here document or "heredoc". You can call it a heredoc (which is correct) but I can also call it a hereis since its roots are back in Unix land when we called it hereis. Or heredoc. Or just here. Or whatever. We knew what we meant. Of course these days we could go on the side of 'might makes right'. Google has 85,400 hits for "heredoc" and "perl" vs. 2,260 for "hereis" and "perl". So I am in a minority but still at least a bit correct. Guess it is time to change that Wikipedia article so that you won't rag me about usage and so that people don't forget their roots. > The code to load that block of text into a variable using a heredoc, I presume, was meant by Mark to be trivial, > not really part of the challenge: Well I agree that your method of just reading the data in to $_ is trivial. But I am not doing it that way but rather am reading the data into a form that I can actually concisely. This was the part that was more difficult for me. Once I was past that then generating the @print was trivial. Only one line even without all of the caveats on forbidden commands. Anyway Tuesday approaches! -- Rick Westerman westerman at purdue.edu Bioinformatics specialist at the Genomics Facility. Phone: (765) 494-0505 FAX: (765) 496-7255 Department of Horticulture and Landscape Architecture 625 Agriculture Mall Drive West Lafayette, IN 47907-2010 Physically located in room S049, WSLR building From mark at ecn.purdue.edu Thu Jan 14 09:41:08 2010 From: mark at ecn.purdue.edu (Mark Senn) Date: Thu, 14 Jan 2010 12:41:08 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <4B4DD501.7030405@purdue.edu> References: <4B4DD501.7030405@purdue.edu> Message-ID: <17106.1263490868@pier.ecn.purdue.edu> On Wed, 13 Jan 2010 09:13:21 -0500 Rick Westerman wrote: > I had a question today as to if is required to use the 'hereis' text > Mark put in his original challenge email. My feeling is 'yes'. Just > filling up an array with serial ASCII characters defeats part of the > challenge -- one could certainly imagine a scenario where arbitrary text > is used in a non-serial manner. But maybe I am saying this because > working with the 'hereis' took most of my less than 2 hour effort (I > almost never use 'hereis') and so want to see what other people come up > with. The original challenge email with some reformattig to make it easier to read and additions made on 2010-01-12 (they're clearly marked): I came across the following when doing normal work for my job. Using the following ==== start with next line 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 DEL ==== end with previous line in a here document set up an array @print in Perl 5 so that elements 0..31 are '.' 32 is ' ' 33..126 are as listed 127 is '.' 128..255 is '.' I'll show my solution (that doesn't use chr do for grep (added on 2010-01-12) if map (added on 2010-01-12) ord repeat (added on 2010-01-12) require (added on 2010-01-14) sub while until use (added on 2010-01-14) ) at next meeting and would like to see other solutions with or without the parenthesized restraint above. -mark One must use the here document in the original challenge email so that, for example, if "R" where changed to "X" in the here document then $print[82] would be "X" after your code runs. There are two kinds of solutions: FIRST KIND: ignores the character numbers like the "0" in "0 NUL" and assumes the values for the @print array are listed in order. SECOND KIND: uses the character numbers so that if, for example, "127 DEL" were changed to "127 x" then $print[127] would be "x" after the code runs. I did an easy to read and understand solution of the first kind. After reading comments by other people, I did a Perl golf solution (minimize number of characters used) of the second kind, and a reformatted version of the Perl golf solution so it is easier to read. -mark From gribskov at purdue.edu Thu Jan 14 11:41:16 2010 From: gribskov at purdue.edu (Michael Gribskov) Date: Thu, 14 Jan 2010 14:41:16 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <17106.1263490868@pier.ecn.purdue.edu> References: <4B4DD501.7030405@purdue.edu> <17106.1263490868@pier.ecn.purdue.edu> Message-ID: <4B4F735C.8090506@purdue.edu> i have a very ugly one statement solution using marks first approach, which doesn't use etc, etc. Mark Senn wrote: > On Wed, 13 Jan 2010 09:13:21 -0500 Rick Westerman wrote: > > I had a question today as to if is required to use the 'hereis' text > > Mark put in his original challenge email. My feeling is 'yes'. Just > > filling up an array with serial ASCII characters defeats part of the > > challenge -- one could certainly imagine a scenario where arbitrary text > > is used in a non-serial manner. But maybe I am saying this because > > working with the 'hereis' took most of my less than 2 hour effort (I > > almost never use 'hereis') and so want to see what other people come up > > with. > > The original challenge email with some reformattig to make it easier to read > and additions made on 2010-01-12 (they're clearly marked): > > I came across the following when doing normal work for my job. > > Using the following > ==== start with next line > 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL > 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI > 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB > 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US > 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' > 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / > 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 > 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? > 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G > 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O > 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W > 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ > 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g > 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o > 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w > 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 DEL > ==== end with previous line > in a here document set up an array @print in Perl 5 so that elements > 0..31 are '.' > 32 is ' ' > 33..126 are as listed > 127 is '.' > 128..255 is '.' > > I'll show my solution (that doesn't use > chr > do > for > grep (added on 2010-01-12) > if > map (added on 2010-01-12) > ord > repeat (added on 2010-01-12) > require (added on 2010-01-14) > sub > while > until > use (added on 2010-01-14) > ) at next meeting and would like to see other solutions with > or without the parenthesized restraint above. -mark > > One must use the here document in the original challenge email so that, > for example, if "R" where changed to "X" in the here document then > $print[82] would be "X" after your code runs. > > There are two kinds of solutions: > > FIRST KIND: ignores the character numbers like the "0" in "0 NUL" and > assumes the values for the @print array are listed in order. > > SECOND KIND: uses the character numbers so that if, for example, "127 DEL" > were changed to "127 x" then $print[127] would be "x" after the code runs. > > I did an easy to read and understand solution of the first kind. After > reading comments by other people, I did a Perl golf solution (minimize > number of characters used) of the second kind, and a reformatted version > of the Perl golf solution so it is easier to read. > > -mark > _______________________________________________ > Purdue-pm mailing list > Purdue-pm at pm.org > http://mail.pm.org/mailman/listinfo/purdue-pm > -- Michael Gribskov Professor of Biological Sciences Purdue University Lilly Hall of Life Sciences 915 W. State Street West Lafayette IN 47907-2054 gribskov at purdue.edu vox: 765.494.6933 fax: 765.496-1189 calendar: http://www.google.com/calendar/embed?src=mgribskov%40gmail.com&ctz=America/New_York From gizmo at purdue.edu Thu Jan 14 18:54:37 2010 From: gizmo at purdue.edu (Joe Kline) Date: Thu, 14 Jan 2010 21:54:37 -0500 Subject: [Purdue-pm] frozen perl 2010 Message-ID: <4B4FD8ED.10802@purdue.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mark's note about YAPC::NA reminded me that I'm going to the Frozen Perl workshop. http://www.frozen-perl.org I'll be taking brian d foy's Effective Perl Programming class. The talks I'm planning on attending are: Testing with Test::More Working Effectively with Legacy Perl Code Building a High Performance Search Engine with Perl and Swish3 Best Coding Practices DBIx::Class in the Real World Catalyst datagrids and you Dancer: The easiest way to develop web applications in Perl? Oddly enough the Effective Perl Programming class is on my birthday. My real present will be going to Punch pizza. joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAktP2O0ACgkQb0mzA2gRTpnE7ACgjRjwvxube2GI1OUDPr8p9o1s J6kAn131vilhsHV/OlkgeKvGljgvUuLJ =N231 -----END PGP SIGNATURE----- From pmiguel at purdue.edu Fri Jan 15 13:34:31 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Fri, 15 Jan 2010 16:34:31 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <17106.1263490868@pier.ecn.purdue.edu> References: <4B4DD501.7030405@purdue.edu> <17106.1263490868@pier.ecn.purdue.edu> Message-ID: <4B50DF67.5090504@purdue.edu> Mark Senn wrote: > On Wed, 13 Jan 2010 09:13:21 -0500 Rick Westerman wrote: > > I had a question today as to if is required to use the 'hereis' text > > Mark put in his original challenge email. My feeling is 'yes'. Just > > filling up an array with serial ASCII characters defeats part of the > > challenge -- one could certainly imagine a scenario where arbitrary text > > is used in a non-serial manner. But maybe I am saying this because > > working with the 'hereis' took most of my less than 2 hour effort (I > > almost never use 'hereis') and so want to see what other people come up > > with. > > The original challenge email with some reformattig to make it easier to read > and additions made on 2010-01-12 (they're clearly marked): > > I came across the following when doing normal work for my job. > > Using the following > ==== start with next line > 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL > 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI > 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB > 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US > 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' > 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / > 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 > 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? > 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G > 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O > 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W > 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ > 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g > 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o > 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w > 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 DEL > ==== end with previous line > in a here document set up an array @print in Perl 5 so that elements > 0..31 are '.' > 32 is ' ' > 33..126 are as listed > 127 is '.' > 128..255 is '.' > > I'll show my solution (that doesn't use > chr > do > for > grep (added on 2010-01-12) > if > map (added on 2010-01-12) > ord > repeat (added on 2010-01-12) > require (added on 2010-01-14) > sub > while > until > use (added on 2010-01-14) > ) at next meeting and would like to see other solutions with > or without the parenthesized restraint above. -mark > > One must use the here document in the original challenge email so that, > for example, if "R" where changed to "X" in the here document then > $print[82] would be "X" after your code runs. > > There are two kinds of solutions: > > FIRST KIND: ignores the character numbers like the "0" in "0 NUL" and > assumes the values for the @print array are listed in order. > > SECOND KIND: uses the character numbers so that if, for example, "127 DEL" > were changed to "127 x" then $print[127] would be "x" after the code runs. > > I did an easy to read and understand solution of the first kind. After > reading comments by other people, I did a Perl golf solution (minimize > number of characters used) of the second kind, and a reformatted version > of the Perl golf solution so it is easier to read. > I now have a single statement (68 characters for the "golf" version--including "@print=" characters) solution which may be of the 1st kind or the 2nd kind. I am presuming that the here doc is dumped into $_ and that step doesn't count against my "score". It is ugly, I guess. But I'm not using any JAPHistry. All the commands I deploy do what you expect them to--they don't rely on some side effect to get the job done. Strictly speaking it is of the 2nd kind in that it passes the test Mark stipulates above. But past that I'm not sure whether it would suit Mark's purposes or not. Phillip From mark at ecn.purdue.edu Sat Jan 16 22:00:56 2010 From: mark at ecn.purdue.edu (Mark Senn) Date: Sun, 17 Jan 2010 01:00:56 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <4B50DF67.5090504@purdue.edu> References: <4B4DD501.7030405@purdue.edu> <17106.1263490868@pier.ecn.purdue.edu> <4B50DF67.5090504@purdue.edu> Message-ID: <22626.1263708056@pier.ecn.purdue.edu> Phillip San Miguel wrote: > I now have a single statement (68 characters for the "golf" > version--including "@print=" characters) solution which may be of the > 1st kind or the 2nd kind. I am presuming that the here doc is dumped > into $_ and that step doesn't count against my "score". It is ugly, I > guess. But I'm not using any JAPHistry. All the commands I deploy do > what you expect them to--they don't rely on some side effect to get > the job done. > > Strictly speaking it is of the 2nd kind in that it passes the test > Mark stipulates above. But past that I'm not sure whether it would > suit Mark's purposes or not. > Phillip Here is a better spec. Changed lines have "+" in column one. + The changes in this document contain information about + o a better description of how the here document should be set up + o a requirement that your program use at least same data from + here document---see the description of the three kinds or solutions + o the array name has changed from print to p + o my solution doesn't use goto + o a third kind of solution has been added (I meant to have this + as the second kind of solution but goofed). The description of + the second kind of solution doesn't make a lot of sense but I'm + not going to change it. + You must have a here document like the following that your program + uses to get the data from. The number of characters used in the + here document isn't included in "perl golf" scores. The here document + should be indented as shown here, so that the "1" of "128" has four spaces + before it. + + [your one-line command to read the here document goes here, it can only + be used to read the data in the here documentn, not do anything else] 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 DEL HERE + Running your program with the above here document should set up an array + p so that elements 0..31 are '.' 32 is ' ' 33..126 are as listed 127 is '.' 128..255 are '.' I'll show my solution (that doesn't use chr do for + goto (added on 2010-01-17) grep (added on 2010-01-12) if map (added on 2010-01-12) ord repeat (added on 2010-01-12) require (added on 2010-01-14) sub while until use (added on 2010-01-14) ) at next meeting and would like to see other solutions with or without the parenthesized restraint above. -mark One must use the here document in the original challenge email so that, for example, if "R" where changed to "X" in the here document then $print[82] would be "X" after your code runs. There are two kinds of solutions: FIRST KIND: ignores the character numbers like the "0" in "0 NUL" and assumes the values for the @print array are listed in order. SECOND KIND: uses the character numbers so that if, for example, "127 DEL" were changed to "127 x" then $print[127] would be "x" after the code runs. + THIRD KIND: uses the character numbers so that if, for example, "127 DEL" + were changed to "40 X" then $print[40] would be "X" after the code runs. I did an easy to read and understand solution of the first kind. After reading comments by other people, I did a Perl golf solution (minimize number of characters used) of the second kind, and a reformatted version of the Perl golf solution so it is easier to read. + Your program must end with the following two lines. These characters + are not included in any Perl golf score. + + use Data::Dumper; + print Dumper @p; -mark From westerman at purdue.edu Tue Jan 19 05:30:53 2010 From: westerman at purdue.edu (Rick Westerman) Date: Tue, 19 Jan 2010 08:30:53 -0500 Subject: [Purdue-pm] Meeting today Message-ID: <4B55B40D.2020400@purdue.edu> Just a reminder for people who believe that work-weeks should begin on a Monday instead of a Tuesday. Meeting today Tuesday Jan 19th, WSLR 116, noon. Meet at 11:30 if you want to chat for a while. -- Rick Westerman westerman at purdue.edu Bioinformatics specialist at the Genomics Facility. Phone: (765) 494-0505 FAX: (765) 496-7255 Department of Horticulture and Landscape Architecture 625 Agriculture Mall Drive West Lafayette, IN 47907-2010 Physically located in room S049, WSLR building From mark at ecn.purdue.edu Tue Jan 19 07:40:28 2010 From: mark at ecn.purdue.edu (Mark Senn) Date: Tue, 19 Jan 2010 10:40:28 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <4B4DDCEF.5000405@purdue.edu> References: <4B4DD501.7030405@purdue.edu> <4B4DDCEF.5000405@purdue.edu> Message-ID: <22207.1263915628@pier.ecn.purdue.edu> > Rick Westerman wrote: > > I had a question today as to if is required to use the 'hereis' > > text Mark put in his original challenge email. My feeling is 'yes'. > > Just filling up an array with serial ASCII characters defeats part > > of the challenge -- one could certainly imagine a scenario where > > arbitrary text is used in a non-serial manner. But maybe I am > > saying this because working with the 'hereis' took most of my less > > than 2 hour effort (I almost never use 'hereis') and so want to see > > what other people come up with. > > > > I am looking forward to Tuesday to see what people come up with. > > TIMTOWTDI !!! > > > > Rick, > The term is not "hereis", it is a here document or "heredoc". See: > > http://en.wikipedia.org/wiki/Heredoc > > I believe Mark's intent is that the string initially be loaded with > the block of text he gave in the email and that code be written to > convert that block of text into the array he describes. > > The code to load that block of text into a variable using a heredoc, I > presume, was meant by Mark to be trivial, not really part of the > challange: > > $_ =<<'END'; > 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL > 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI > 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB > 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US > 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' > 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / > 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 > 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? > 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G > 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O > 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W > 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ > 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g > 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o > 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w > 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 DEL > END > > Or did I misinterpret you Mark? > Phillip Phillip, Sorry for the late reply. You didn't misintrepret. -mark From pmiguel at purdue.edu Tue Jan 19 07:56:10 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Tue, 19 Jan 2010 10:56:10 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <22207.1263915628@pier.ecn.purdue.edu> References: <4B4DD501.7030405@purdue.edu> <4B4DDCEF.5000405@purdue.edu> <22207.1263915628@pier.ecn.purdue.edu> Message-ID: <4B55D61A.8070408@purdue.edu> Mark Senn wrote: >> Rick Westerman wrote: >> >>> I had a question today as to if is required to use the 'hereis' >>> text Mark put in his original challenge email. My feeling is 'yes'. >>> Just filling up an array with serial ASCII characters defeats part >>> of the challenge -- one could certainly imagine a scenario where >>> arbitrary text is used in a non-serial manner. But maybe I am >>> saying this because working with the 'hereis' took most of my less >>> than 2 hour effort (I almost never use 'hereis') and so want to see >>> what other people come up with. >>> >>> I am looking forward to Tuesday to see what people come up with. >>> TIMTOWTDI !!! >>> >>> >> Rick, >> The term is not "hereis", it is a here document or "heredoc". See: >> >> http://en.wikipedia.org/wiki/Heredoc >> >> I believe Mark's intent is that the string initially be loaded with >> the block of text he gave in the email and that code be written to >> convert that block of text into the array he describes. >> >> The code to load that block of text into a variable using a heredoc, I >> presume, was meant by Mark to be trivial, not really part of the >> challange: >> >> $_ =<<'END'; >> 0 NUL 1 SOH 2 STX 3 ETX 4 EOT 5 ENQ 6 ACK 7 BEL >> 8 BS 9 HT 10 NL 11 VT 12 NP 13 CR 14 SO 15 SI >> 16 DLE 17 DC1 18 DC2 19 DC3 20 DC4 21 NAK 22 SYN 23 ETB >> 24 CAN 25 EM 26 SUB 27 ESC 28 FS 29 GS 30 RS 31 US >> 32 SP 33 ! 34 " 35 # 36 $ 37 % 38 & 39 ' >> 40 ( 41 ) 42 * 43 + 44 , 45 - 46 . 47 / >> 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 >> 56 8 57 9 58 : 59 ; 60 < 61 = 62 > 63 ? >> 64 @ 65 A 66 B 67 C 68 D 69 E 70 F 71 G >> 72 H 73 I 74 J 75 K 76 L 77 M 78 N 79 O >> 80 P 81 Q 82 R 83 S 84 T 85 U 86 V 87 W >> 88 X 89 Y 90 Z 91 [ 92 \ 93 ] 94 ^ 95 _ >> 96 ` 97 a 98 b 99 c 100 d 101 e 102 f 103 g >> 104 h 105 i 106 j 107 k 108 l 109 m 110 n 111 o >> 112 p 113 q 114 r 115 s 116 t 117 u 118 v 119 w >> 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 DEL >> END >> >> Or did I misinterpret you Mark? >> Phillip >> > > Phillip, Sorry for the late reply. You didn't misintrepret. -mark > > Mark, Great. Will be interesting to see the various solutions today. Phillip From pmiguel at purdue.edu Tue Jan 19 11:54:41 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Tue, 19 Jan 2010 14:54:41 -0500 Subject: [Purdue-pm] More on Mark's challenge In-Reply-To: <22207.1263915628@pier.ecn.purdue.edu> References: <4B4DD501.7030405@purdue.edu> <4B4DDCEF.5000405@purdue.edu> <22207.1263915628@pier.ecn.purdue.edu> Message-ID: <4B560E01.4060901@purdue.edu> With regards to the solution I had using 'split', it does work: #split plus hash slice method my %here =split; my @p =@here{0..127}; @p[0..32,127..255] =split //, q{.}x32 .q{ } .q{.}x129; But it does require no pattern to be specified to invoke the desired magic. From perldoc -f split: split /PATTERN/,EXPR,LIMIT split /PATTERN/,EXPR split /PATTERN/ split [...] If EXPR is omitted, splits the $_ string. If PATTERN is also omitted, splits on whitespace (after skipping any leading whitespace). Phillip PS I have updated my "golf" solution to 43 characters: @p=(('.')x32,' ',/\d+\s(\S)\s/g,('.')x129); Commented, it isn't even difficult to understand: @p =( ('.')x32 #1st 32 characters are '.' ,' ' #the requisite space ,/\d+\s(\S)\s/g #capture 1 character records ,('.')x129 #round out to 256 elements ); But it is brittle... From jacoby at purdue.edu Tue Jan 19 12:03:14 2010 From: jacoby at purdue.edu (Dave Jacoby) Date: Tue, 19 Jan 2010 15:03:14 -0500 Subject: [Purdue-pm] Possible February Challenge Message-ID: <4B561002.7070300@purdue.edu> This is one I heard on NPR quite some time ago. Take the phrase "Pre-Christmas Sale". Break it up into a 4x4 block. P R E C H R I S T M A S S A L E The challenge was to find the longest word you can find within this block. You can go up-down, left-right or diagonally. You cannot reuse a letter, but you can "cross the stream". Meaning, if there was such a word as "AESL", assuming "P" as element[0][0] of this array of arrays, that would be [3,3], [4,4], [3,4], [4,3] (or vice versa, depending on how you count) and perfectly legitimate. Basically, we're programming the computer to play Boggle. Using my canon, there are 6 eight-letter words and no nine-letter words. Running `time scramble.pl` on my desktop, I got this: real 6m21.935s user 2m54.799s sys 0m1.620s Anyone up for this challenge? -- Dave Jacoby Address: WSLR S049 Genomics Core Programmer Mail: jacoby at purdue.edu Purdue University Jabber: jacoby at jabber.org Phone: 765.49.67368 From jacoby at purdue.edu Tue Jan 19 12:54:40 2010 From: jacoby at purdue.edu (Dave Jacoby) Date: Tue, 19 Jan 2010 15:54:40 -0500 Subject: [Purdue-pm] Possible February Challenge In-Reply-To: <20280.1263931856@pier.ecn.purdue.edu> References: <4B561002.7070300@purdue.edu> <20280.1263931856@pier.ecn.purdue.edu> Message-ID: <4B561C10.9070209@purdue.edu> Yes, MASLI would be illegal. You have to go to adjacent letters. I used dictionaries found in the CERIAS FTP site. [http://ftp.cerias.purdue.edu/pub/dict/] It has grown since the last I downloaded. I'm trying my code with the words from Webster's Dictionary. http://ftp.cerias.purdue.edu/pub/dict/dictionaries/English/Webster/ I know there's one winning word that is not within that dictionary, but it's the most common in standard usage. Let's make that the official word-list of this challenge. Mark Senn wrote: > > Take the phrase "Pre-Christmas Sale". Break it up into a 4x4 block. > > > > P R E C > > H R I S > > T M A S > > S A L E > > > > The challenge was to find the longest word you can find within this > > block. You can go up-down, left-right or diagonally. You cannot reuse > > a letter, but you can "cross the stream". Meaning, if there was such a > > word as "AESL", assuming "P" as element[0][0] of this array of arrays, > > that would be [3,3], [4,4], [3,4], [4,3] (or vice versa, depending on > > how you count) and perfectly legitimate. Basically, we're programming > > the computer to play Boggle. > > Just want to make sure I understand what "crossing the stream" means. > > The sequence of letters MASLI would be illegal, right? -mark -- Dave Jacoby Address: WSLR S049 Genomics Core Programmer Mail: jacoby at purdue.edu Purdue University Jabber: jacoby at jabber.org Phone: 765.49.67368 From jacoby at purdue.edu Tue Jan 19 13:07:39 2010 From: jacoby at purdue.edu (Dave Jacoby) Date: Tue, 19 Jan 2010 16:07:39 -0500 Subject: [Purdue-pm] Possible February Challenge In-Reply-To: <29087.1263934638@pier.ecn.purdue.edu> References: <4B561002.7070300@purdue.edu> <29087.1263934638@pier.ecn.purdue.edu> Message-ID: <4B561F1B.8080006@purdue.edu> I see in this group all the enthusiasm for Perl 6 in our group that Soviet apparatchiks had for the coming of Glasnost. I figure that, like today's meeting, everyone will write Perl 5 code if it isn't explicit, and if I explicitly say Perl $n where $n != 5, participation will fall off. I for one would like to see Perl 6 used in a sense that isn't pure example code, so if you want to take a shot, I'd be glad to see it. If someone wants to try it in Perl 2, perhaps a little less so. B) Mark Senn wrote: > > Take the phrase "Pre-Christmas Sale". Break it up into a 4x4 block. > > You may want to explicitly say which language to use. > I suggest Perl 5 or perl 6. -mark -- Dave Jacoby Address: WSLR S049 Genomics Core Programmer Mail: jacoby at purdue.edu Purdue University Jabber: jacoby at jabber.org Phone: 765.49.67368 From jacoby at purdue.edu Wed Jan 20 10:42:54 2010 From: jacoby at purdue.edu (Dave Jacoby) Date: Wed, 20 Jan 2010 13:42:54 -0500 Subject: [Purdue-pm] Describing Perl 6 as a job humans won't do Message-ID: <4B574EAE.8060900@purdue.edu> http://www.youtube.com/watch?v=gKcZdqkyJz4 -- Dave Jacoby Address: WSLR S049 Genomics Core Programmer Mail: jacoby at purdue.edu Purdue University Jabber: jacoby at jabber.org Phone: 765.49.67368 From pmiguel at purdue.edu Fri Jan 29 06:15:49 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Fri, 29 Jan 2010 09:15:49 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array Message-ID: <4B62ED95.808@purdue.edu> This is probably pretty straight forward, but: I have a hash of 2d arrays. I want to sort by numerical value across one of these dimensions. What would be the syntax for that? $table{$colors}[0..num_of_traces-1][0..num_data_points-1] I want sort the values in the first (traces) dimension. When I try to write the sort syntax my head starts spinning. -- Phillip From gizmo at purdue.edu Fri Jan 29 07:11:10 2010 From: gizmo at purdue.edu (Joe Kline) Date: Fri, 29 Jan 2010 10:11:10 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B62ED95.808@purdue.edu> References: <4B62ED95.808@purdue.edu> Message-ID: <4B62FA8E.5040906@purdue.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Phillip San Miguel wrote: > This is probably pretty straight forward, but: > > I have a hash of 2d arrays. I want to sort by numerical value across one > of these dimensions. What would be the syntax for that? > > $table{$colors}[0..num_of_traces-1][0..num_data_points-1] > > I want sort the values in the first (traces) dimension. > > When I try to write the sort syntax my head starts spinning. > wouldn't it just be: @sorted = sort { $a->[0] <=> $b->[0] } @{ $table{$colors} }; ? if you want to sort by data points the index for the sort would be [1], wouldn't it? joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org iD8DBQFLYvqNb0mzA2gRTpkRAqtOAJ9Hg/UDimmea+0Kk9HlIzWzvDxroQCffk9u fQkzSRbkno7oeymFc553g7s= =vkRD -----END PGP SIGNATURE----- From westerman at purdue.edu Fri Jan 29 07:18:27 2010 From: westerman at purdue.edu (Rick Westerman) Date: Fri, 29 Jan 2010 10:18:27 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B62ED95.808@purdue.edu> References: <4B62ED95.808@purdue.edu> Message-ID: <35956819-A3B9-49E1-A61D-FECFF998270E@purdue.edu> On Jan 29, 2010, at 9:15 AM, Phillip San Miguel wrote: > This is probably pretty straight forward, but: > > I have a hash of 2d arrays. I want to sort by numerical value > across one of these dimensions. What would be the syntax for that? > > $table{$colors}[0..num_of_traces-1][0..num_data_points-1] > > I want sort the values in the first (traces) dimension. > > When I try to write the sort syntax my head starts spinning. > > -- > I found myself floundering as well but then realized that it was because I was unsure what you wanted. Also because the problem is difficult! Using an example and using %t instead of %table, let us say you have: $t{red}[0,0] $t{green}[2,0] $t{blue}[1,0] $t{blue}[4,0] $t{red}[2,0] $t{blue}[0,0] Do you want the sort to look like: $t{red}[0,0] $t{blue}[0,0] $t{blue}[1,0] $t{green}[2,0] $t{red}[2,0] $t{blue}[4,0] Or like: $t{red}[0,0] $t{red}[2,0] $t{green}[2,0] $t{blue}[1,0] $t{blue}[0,0] $t{blue}[4,0] In others all color data jumbled together or per-color data sorted? Assuming the latter (which makes more sense to me) then I would do multiple sorts so that the sort would look like: my %sorted; @{$sorted{$color}} = sort { $a->[0] <=> $b->[0] } @{$table{$color}} foreach my $color (keys %table); There might be a way to combine the sort into one mega-sort but that would hurt my brain. Test program (with more data) is enclosed. Let us know if you want the data sorted in a different way. -------------- next part -------------- A non-text attachment was scrubbed... Name: t.pl Type: text/x-perl-script Size: 474 bytes Desc: not available URL: -------------- next part -------------- -- Rick From pmiguel at purdue.edu Fri Jan 29 07:35:16 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Fri, 29 Jan 2010 10:35:16 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B62FA8E.5040906@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> Message-ID: <4B630034.6070902@purdue.edu> Joe Kline wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Phillip San Miguel wrote: > >> This is probably pretty straight forward, but: >> >> I have a hash of 2d arrays. I want to sort by numerical value across one >> of these dimensions. What would be the syntax for that? >> >> $table{$colors}[0..num_of_traces-1][0..num_data_points-1] >> >> I want sort the values in the first (traces) dimension. >> >> When I try to write the sort syntax my head starts spinning. >> >> > > wouldn't it just be: > > @sorted = sort { $a->[0] <=> $b->[0] } @{ $table{$colors} }; > > ? > > if you want to sort by data points the index for the sort would be [1], > wouldn't it? > > joe > > I guess I don't understand what that would be doing. @{ $table{$colors} } would return a list of arrays of pointers to other arrays. $b->[0] and $a->[0] Seems like they would return pointers to the second dimension of the array. So wouldn't they sort the pointers themselves? Phillip From pmiguel at purdue.edu Fri Jan 29 07:45:37 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Fri, 29 Jan 2010 10:45:37 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B630034.6070902@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> Message-ID: <4B6302A1.9030705@purdue.edu> Phillip San Miguel wrote: > Joe Kline wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Phillip San Miguel wrote: >> >>> This is probably pretty straight forward, but: >>> >>> I have a hash of 2d arrays. I want to sort by numerical value across >>> one >>> of these dimensions. What would be the syntax for that? >>> >>> $table{$colors}[0..num_of_traces-1][0..num_data_points-1] >>> >>> I want sort the values in the first (traces) dimension. >>> >>> When I try to write the sort syntax my head starts spinning. >>> >>> >> >> wouldn't it just be: >> >> @sorted = sort { $a->[0] <=> $b->[0] } @{ $table{$colors} }; >> >> ? >> >> if you want to sort by data points the index for the sort would be [1], >> wouldn't it? >> >> joe >> >> > I guess I don't understand what that would be doing. > > @{ $table{$colors} } > > would return a list of arrays of pointers to other arrays. > > $b->[0] > and > $a->[0] > > > Seems like they would return pointers to the second dimension of the > array. So wouldn't they sort the pointers themselves? > > Phillip That said, the syntax you provide, in practice, does do exactly what I needed... From bradley.d.andersen at gmail.com Fri Jan 29 07:47:27 2010 From: bradley.d.andersen at gmail.com (Bradley Andersen) Date: Fri, 29 Jan 2010 10:47:27 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B6302A1.9030705@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> <4B6302A1.9030705@purdue.edu> Message-ID: <161651541001290747r456b7e3dxed043486fcef527b@mail.gmail.com> I have this habit of not sending code I have not tested ... perhaps Joe works in the same manner? ;-P On Fri, Jan 29, 2010 at 10:45 AM, Phillip San Miguel wrote: > Phillip San Miguel wrote: >> >> Joe Kline wrote: >>> >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> Phillip San Miguel wrote: >>> >>>> >>>> This is probably pretty straight forward, but: >>>> >>>> I have a hash of 2d arrays. I want to sort by numerical value across one >>>> of these dimensions. What would be the syntax for that? >>>> >>>> $table{$colors}[0..num_of_traces-1][0..num_data_points-1] >>>> >>>> I want sort the values in the first (traces) dimension. >>>> >>>> When I try to write the sort syntax my head starts spinning. >>>> >>>> >>> >>> wouldn't it just be: >>> >>> @sorted = sort { $a->[0] <=> $b->[0] } @{ $table{$colors} }; >>> >>> ? >>> >>> if you want to sort by data points the index for the sort would be [1], >>> wouldn't it? >>> >>> joe >>> >>> >> >> I guess I don't understand what that would be doing. >> >> @{ $table{$colors} } >> >> would return a list of arrays of pointers to other arrays. >> >> $b->[0] >> and >> $a->[0] >> >> >> Seems like they would return pointers to the second dimension of the >> array. So wouldn't they sort the pointers themselves? >> >> Phillip > > That said, the syntax you provide, in practice, does do exactly what I > needed... > _______________________________________________ > Purdue-pm mailing list > Purdue-pm at pm.org > http://mail.pm.org/mailman/listinfo/purdue-pm > From pmiguel at purdue.edu Fri Jan 29 07:56:40 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Fri, 29 Jan 2010 10:56:40 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B6302A1.9030705@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> <4B6302A1.9030705@purdue.edu> Message-ID: <4B630538.2040507@purdue.edu> Phillip San Miguel wrote: > >> > That said, the syntax you provide, in practice, does do exactly what I > needed... Spoke too soon, no that isn't what I meant. Discarding the hash part--which isn't the problem. I have a 2D array. If I sort it your way, I get: perl -e '@a=([7,0,25,10],[0,9,7,12],[3,2,1,0]);@sorted=sort {$a->[0] <=> $b->[0]} @a ;use Data::Dumper; print Dumper \@a;print Dumper \@sorted;' $VAR1 = [ [ 7, 0, 25, 10 ], [ 0, 9, 7, 12 ], [ 3, 2, 1, 0 ] ]; $VAR1 = [ [ 0, 9, 7, 12 ], [ 3, 2, 1, 0 ], [ 7, 0, 25, 10 ] ]; But what I want is: $VAR1 = [ [ 0, 0, 1, 0 ], [ 3, 2, 7, 10 ], [ 7, 9, 25, 12 ] ]; From jacoby at purdue.edu Fri Jan 29 08:08:40 2010 From: jacoby at purdue.edu (Dave Jacoby) Date: Fri, 29 Jan 2010 11:08:40 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B630538.2040507@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> <4B6302A1.9030705@purdue.edu> <4B630538.2040507@purdue.edu> Message-ID: <4B630808.809@purdue.edu> So, you're wanting to sort the inner arrays. my $x = [[7,0,25,10],[0,9,7,12],[3,2,1,0]] ; say Dumper $x ; for my $y ( @$x ) { @$y = sort { $a <=> $b } @$y ; } say Dumper $x ; jacoby at oz:~$ ./test.pl line 64. $VAR1 = [ [ 7, 0, 25, 10 ], [ 0, 9, 7, 12 ], [ 3, 2, 1, 0 ] ]; $VAR1 = [ [ 0, 7, 10, 25 ], [ 0, 7, 9, 12 ], [ 0, 1, 2, 3 ] ]; jacoby at oz:~$ There may be a more clever choice, but that works as I understand you want it to. Phillip San Miguel wrote: > Phillip San Miguel wrote: >> >>> >> That said, the syntax you provide, in practice, does do exactly what I >> needed... > Spoke too soon, no that isn't what I meant. Discarding the hash > part--which isn't the problem. I have a 2D array. If I sort it your way, > I get: > > perl -e '@a=([7,0,25,10],[0,9,7,12],[3,2,1,0]);@sorted=sort {$a->[0] <=> > $b->[0]} @a ;use Data::Dumper; print Dumper \@a;print Dumper \@sorted;' > > > $VAR1 = [ > [ > 7, > 0, > 25, > 10 > ], > [ > 0, > 9, > 7, > 12 > ], > [ > 3, > 2, > 1, > 0 > ] > ]; > $VAR1 = [ > [ > 0, > 9, > 7, > 12 > ], > [ > 3, > 2, > 1, > 0 > ], > [ > 7, > 0, > 25, > 10 > ] > ]; > > But what I want is: > $VAR1 = [ > [ > 0, > 0, > 1, > 0 > ], > [ > 3, > 2, > 7, > 10 > ], > [ > 7, > 9, > 25, > 12 > ] > ]; > > > _______________________________________________ > Purdue-pm mailing list > Purdue-pm at pm.org > http://mail.pm.org/mailman/listinfo/purdue-pm -- Dave Jacoby Address: WSLR S049 Genomics Core Programmer Mail: jacoby at purdue.edu Purdue University Jabber: jacoby at jabber.org Phone: 765.49.67368 From westerman at purdue.edu Fri Jan 29 08:11:17 2010 From: westerman at purdue.edu (Rick Westerman) Date: Fri, 29 Jan 2010 11:11:17 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B630538.2040507@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> <4B6302A1.9030705@purdue.edu> <4B630538.2040507@purdue.edu> Message-ID: <08DDE2DD-8EBF-4D5E-99DE-0FF4D90252BC@purdue.edu> So if I am not missing something here, basically you have an array of arrays but then are deconstructing the data into separate arrays thus destroying any relationship between the data. That seems strange to me. But if so I'd map all of the data into their separate arrays, sort those arrays and then remap that the information into your array of arrays. Or just skip that final step and deal with the separate arrays since the data no longer has any relationship. -- Rick > Phillip San Miguel wrote: >> >>> >> That said, the syntax you provide, in practice, does do exactly >> what I needed... > Spoke too soon, no that isn't what I meant. Discarding the hash > part--which isn't the problem. I have a 2D array. If I sort it your > way, I get: > > perl -e '@a=([7,0,25,10],[0,9,7,12],[3,2,1,0]);@sorted=sort {$a-> > [0] <=> $b->[0]} @a ;use Data::Dumper; print Dumper \@a;print > Dumper \@sorted;' > > > $VAR1 = [ > [ > 7, > 0, > 25, > 10 > ], > [ > 0, > 9, > 7, > 12 > ], > [ > 3, > 2, > 1, > 0 > ] > ]; > $VAR1 = [ > [ > 0, > 9, > 7, > 12 > ], > [ > 3, > 2, > 1, > 0 > ], > [ > 7, > 0, > 25, > 10 > ] > ]; > > But what I want is: > $VAR1 = [ > [ > 0, > 0, > 1, > 0 > ], > [ > 3, > 2, > 7, > 10 > ], > [ > 7, > 9, > 25, > 12 > ] > ]; > > > _______________________________________________ > Purdue-pm mailing list > Purdue-pm at pm.org > http://mail.pm.org/mailman/listinfo/purdue-pm From gizmo at purdue.edu Fri Jan 29 08:19:03 2010 From: gizmo at purdue.edu (Joe Kline) Date: Fri, 29 Jan 2010 11:19:03 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <08DDE2DD-8EBF-4D5E-99DE-0FF4D90252BC@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> <4B6302A1.9030705@purdue.edu> <4B630538.2040507@purdue.edu> <08DDE2DD-8EBF-4D5E-99DE-0FF4D90252BC@purdue.edu> Message-ID: <4B630A77.7020300@purdue.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Rick Westerman wrote: > So if I am not missing something here, basically you have an array > of arrays but then are deconstructing the data into separate arrays thus > destroying any relationship between the data. That seems strange to > me. But if so I'd map all of the data into their separate arrays, sort > those arrays and then remap that the information into your array of > arrays. Or just skip that final step and deal with the separate arrays > since the data no longer has any relationship. Here's a perlmonks node about this: http://www.perlmonks.org/?node_id=15209 joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org iD8DBQFLYwp2b0mzA2gRTpkRAsQuAJ4pTyUzWDGmoUttUhzq9thnNY+qiACfWrGl a1Oh5uxUjvtpUhTSkNudm7g= =A5Co -----END PGP SIGNATURE----- From westerman at purdue.edu Fri Jan 29 08:27:06 2010 From: westerman at purdue.edu (Rick Westerman) Date: Fri, 29 Jan 2010 11:27:06 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B630808.809@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> <4B6302A1.9030705@purdue.edu> <4B630538.2040507@purdue.edu> <4B630808.809@purdue.edu> Message-ID: On Jan 29, 2010, at 11:08 AM, Dave Jacoby wrote: > So, you're wanting to sort the inner arrays. Dave: Although your solution is good for sorting inner arrays it does not replicate what Phillip stated in his example. Phillip's example still seems bizarre to me but there is probably a good reason behind it. Dave's output > > $VAR1 = [ > [ > 0, > 7, > 10, > 25 > ], > [ > 0, > 7, > 9, > 12 > ], > [ > 0, > 1, > 2, > 3 > ] > ]; > > Phillip's desired output: >> But what I want is: >> $VAR1 = [ >> [ >> 0, >> 0, >> 1, >> 0 >> ], >> [ >> 3, >> 2, >> 7, >> 10 >> ], >> [ >> 7, >> 9, >> 25, >> 12 >> ] >> ]; -- Rick From jacoby at purdue.edu Fri Jan 29 08:55:45 2010 From: jacoby at purdue.edu (Dave Jacoby) Date: Fri, 29 Jan 2010 11:55:45 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> <4B6302A1.9030705@purdue.edu> <4B630538.2040507@purdue.edu> <4B630808.809@purdue.edu> Message-ID: <4B631311.5000505@purdue.edu> So I fundamentally misunderstood the issue. OK. This is the input, put into table form. 7 0 25 10 0 9 7 12 3 2 1 0 This is the desired output. 0 0 1 0 3 2 7 10 7 9 25 12 OK, now I get it. Kinda $x[$b][$a] instead of $x[$a][$b]. So, thinking of it as a table or matrix instead of an array of arrays. Not unreasonable, but computer science discourages thinking like that. Rick Westerman wrote: > > On Jan 29, 2010, at 11:08 AM, Dave Jacoby wrote: > >> So, you're wanting to sort the inner arrays. > > Dave: > > Although your solution is good for sorting inner arrays it does not > replicate what Phillip stated in his example. Phillip's example still > seems bizarre to me but there is probably a good reason behind it. > > Dave's output >> >> $VAR1 = [ >> [ >> 0, >> 7, >> 10, >> 25 >> ], >> [ >> 0, >> 7, >> 9, >> 12 >> ], >> [ >> 0, >> 1, >> 2, >> 3 >> ] >> ]; >> >> > > > Phillip's desired output: > > >>> But what I want is: >>> $VAR1 = [ >>> [ >>> 0, >>> 0, >>> 1, >>> 0 >>> ], >>> [ >>> 3, >>> 2, >>> 7, >>> 10 >>> ], >>> [ >>> 7, >>> 9, >>> 25, >>> 12 >>> ] >>> ]; > > > -- Rick > > _______________________________________________ > Purdue-pm mailing list > Purdue-pm at pm.org > http://mail.pm.org/mailman/listinfo/purdue-pm -- Dave Jacoby Address: WSLR S049 Genomics Core Programmer Mail: jacoby at purdue.edu Purdue University Jabber: jacoby at jabber.org Phone: 765.49.67368 From pmiguel at purdue.edu Fri Jan 29 09:17:29 2010 From: pmiguel at purdue.edu (Phillip San Miguel) Date: Fri, 29 Jan 2010 12:17:29 -0500 Subject: [Purdue-pm] How to sort one dimension of a 2d array In-Reply-To: <4B630A77.7020300@purdue.edu> References: <4B62ED95.808@purdue.edu> <4B62FA8E.5040906@purdue.edu> <4B630034.6070902@purdue.edu> <4B6302A1.9030705@purdue.edu> <4B630538.2040507@purdue.edu> <08DDE2DD-8EBF-4D5E-99DE-0FF4D90252BC@purdue.edu> <4B630A77.7020300@purdue.edu> Message-ID: <4B631829.70404@purdue.edu> Joe Kline wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Rick Westerman wrote: > >> So if I am not missing something here, basically you have an array >> of arrays but then are deconstructing the data into separate arrays thus >> destroying any relationship between the data. That seems strange to >> me. But if so I'd map all of the data into their separate arrays, sort >> those arrays and then remap that the information into your array of >> arrays. Or just skip that final step and deal with the separate arrays >> since the data no longer has any relationship. >> > > Here's a perlmonks node about this: > > http://www.perlmonks.org/?node_id=15209 > > joe > Thanks everyone. The discussion was useful for me. BTW, I'm not doing anything strange. Just the equivalent of starting with: 7 0 25 10 0 9 7 12 3 2 1 0 and sorting the columns: 0 0 1 0 3 2 7 10 7 9 25 12 Which allows me to get max and median values for each column. (Rick, each row is a different trace file and each column is a scan.) -- Phillip