David Cantrell wrote:
> On Sat, Sep 12, 2009 at 06:03:44PM +0100, Lyle wrote:
>   
>> my @array = (?one?, ?two?);
>>
>> stores ?one? at location 0 and ?two? at location 1. This is an important 
>> thing to note with a lot of computer arithmetic, numbering generally 
>> starts at 0.
>>     
>
> To avoid confusion between one and 1, I suggest putting other data into
> The array - aardvark, bat, coelocanth etc
>   

Agreed.

>> The default sort is an ASCII one, so A-Z goes before a-z. We'll cover 
>> more on sorting later.
>>     
>
> Isn't cmp locale-sensitive?
>   

Not sure. I get the feeling it depends on your Perl version and use utf8.

>> The if statement allows you to run a block of code if a condition is 
>> true. They are in the format:-
>>
>> if ( CONDITION ) {
>> CODE
>> }#if
>>     
>
> Twitch twitch indentation twitch
>   

There is in the printed version :)

>> # Wrong way
>> if ( $value = 0 ) { } # True
>>     
>
> False.
>   

Oops. You know I thought that at the time, but wrote it about 10mins 
before I had to leave to teach the class and didn't have time to test. A 
better example would be

my $value = 2;
if ( $value = 1 ) { } # True

>> You also have OR, ||, AND, &&. OR and || do basically the same thing, as 
>> do AND and &&. There are subtle differences in preference, but I won't 
>> be covering them as the vast majority of the time they are interchangeable.
>>     
>
> or and || are only subtlely different from and and &&?  Errm.  HELL NO.
> I presume you're trying to make the point that or and || are roughly the
> same and that and and && are also, but this needs re-writing.
>   

I finally got around to buying a book on grammar the other day :D

> Also note that capitalisation is significant.  OR is a user-defined
> function, or is a built-in operator.
>
>   
>> For general convenience and to make things read easier, unless is 
>> provided as an alternative to if not.
>>
>> if ( not( 9 > 10 ) ) { } # True
>> unless ( 9 > 10 ) { } # Same
>>     
>
> You may want to make the point that no-one in their right mind does this
> ...
>
> unless(...) {
>   ...
> } else {
>   ...
> }
>
> Because it's incredibly hard to parse in English.
>   

Agreed.

> On an unrelated note, it seems that you're doing things in a bit of a
> weird order.  I think aggregate data-types (arrays and hashes) should
> be treated together, so move the section about comparisons and
> conditionals to between scalars and arrays/hashes.
>   

These kids are young and for the most part know nothing of programming. 
Trying to teach them by the normal pattern just isn't going to work. 
I've got it broken down like this because I had them writing/running 
lots of examples along the way.

I'm sure the order could be better, but throwing in things like the x 
string multiplier helped keep their interest. They all found filling 
their screens with lots of repeated text very amusing.


Lyle

_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to