Home Accessibility Courses Diary The Mouth Facebook Resources Site Map About Us Contact
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
The dog is not in trouble

Dog in the fields"I know I put my papers somewhere" I said to Lisa [wife], and Gypsy [dog] goes off and whimpers in the corner, looking very guilty.

So had she [dog] taken the papers and chewed them? That wasn't the case - she had heard the word "no" (or rather "know") in what I said, and had taken it that she was being told off for something.

We heard words and take them in context - they mean different things depending on the rest of the sentence surrounding them. "We don't subsidise lunches" could mean 'as a matter of policy we will never pay part of the cost of your lunch', or it could mean 'as it happens, we don't at the moment make any payment towards your lunch in our canteen'. And - taken out of context - this is an awfully good way of manipulating a message (or a naughty way, depending on your print of view).

It may surprise newcomers to programming that context also comes in to computer languages - a simple ^ (caret character) means different things in different places, and it's far from unique in having different meanings,


print "Say something: "
saying = gets.chop
 
puts "That starts with W" if saying =~ /^W/
puts "That contains a character which is not a letter" if saying =~ /[^A-Za-z]/
print 160 ^ 54, " shows the bitwise exclusive or operator\n"


So that's "Starts With" or "Anything Except" or "Either but not Both depending on what else is written around it. The example I have given is in Ruby, but the three meanings are the same in many other languages - thank goodness for that consistency, at least!

Running that code ...

Dorothy-2:jul09 grahamellis$ ruby csdp
Say something: Wicked
That starts with W
150 shows the bitwise exclusive or operator
Dorothy-2:jul09 grahamellis$ ruby csdp
Say something: Sweet Summer Sunshine
That contains a character which is not a letter
150 shows the bitwise exclusive or operator
Dorothy-2:jul09 grahamellis$


Some languages such as Perl make a very heavy use of context - if I write @abc, I could be referring to all the elements of a list, to the length of the list, or to the list expanded into a string. See article on context in Perl.

While checking this article, Google found me a rather nice Ruby Quick Reference - enjoy!


(written 2009-07-17, updated 2009-07-18)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P208 - Perl - Lists
  [3939] Lots of ways of doing the same thing in Perl - list iteration - (2012-12-03)
  [3906] Taking the lead, not the dog, for a walk. - (2012-10-28)
  [3870] Writing more maintainable Perl - naming fields from your data records - (2012-09-25)
  [3669] Stepping through a list (or an array) in reverse order - (2012-03-23)
  [3548] Dark mornings, dog update, and Python and Lua courses before Christmas - (2011-12-10)
  [3400] $ is atomic and % and @ are molecular - Perl - (2011-08-20)
  [2996] Copying - duplicating data, or just adding a name? Perl and Python compared - (2010-10-12)
  [2833] Fresh Perl Teaching Examples - part 2 of 3 - (2010-06-27)
  [2813] Iterating over a Perl list and changing all items - (2010-06-15)
  [2484] Finding text and what surrounds it - contextual grep - (2009-10-30)
  [2226] Revision / Summary of lists - Perl - (2009-06-10)
  [2067] Perl - lists do so much more than arrays - (2009-03-05)
  [1918] Perl Socket Programming Examples - (2008-12-02)
  [1917] Out of memory during array extend - Perl - (2008-12-02)
  [1828] Perl - map to process every member of a list (array) - (2008-10-09)
  [1703] Perl ... adding to a list - end, middle, start - (2008-07-09)
  [1316] Filtering and altering Perl lists with grep and map - (2007-08-23)
  [1304] Last elements in a Perl or Python list - (2007-08-16)
  [968] Perl - a list or a hash? - (2006-12-06)
  [928] C++ and Perl - why did they do it THAT way? - (2006-11-16)
  [773] Breaking bread - (2006-06-22)
  [762] Huge data files - what happened earlier? - (2006-06-15)
  [622] Queues and barrel rolls in Perl - (2006-02-24)
  [560] The fencepost problem - (2006-01-10)
  [463] Splitting the difference - (2005-10-13)
  [355] Context in Perl - (2005-06-22)
  [240] Conventional restraints removed - (2005-03-09)
  [230] Course sizes - beware of marketing statistics - (2005-02-27)
  [140] Comparison Chart for Perl programmers - list functions - (2004-12-04)
  [28] Perl for breakfast - (2004-08-25)

R109 - Ruby - Strings and Regular Expressions
  [3758] Ruby - standard operators are overloaded. Perl - they are not - (2012-06-09)
  [3757] Ruby - a teaching example showing many of the language features in short but useful program - (2012-06-09)
  [3621] Matching regular expressions, and substitutions, in Ruby - (2012-02-23)
  [3424] Divide 10000 by 17. Do you get 588.235294117647, 588.24 or 588? - Ruby and PHP - (2011-09-08)
  [2980] Ruby - examples of regular expressions, inheritance and polymorphism - (2010-10-02)
  [2623] Object Oriented Ruby - new examples - (2010-02-03)
  [2621] Ruby collections and strings - some new examples - (2010-02-03)
  [2614] Neatly formatting results into a table - (2010-02-01)
  [2608] Search and replace in Ruby - Ruby Regular Expressions - (2010-01-31)
  [2293] Regular Expressions in Ruby - (2009-07-16)
  [1891] Ruby to access web services - (2008-11-16)
  [1887] Ruby Programming Course - Saturday and Sunday - (2008-11-16)
  [1875] What are exceptions - Python based answer - (2008-11-08)
  [1588] String interpretation in Ruby - (2008-03-21)
  [1305] Regular expressions made easy - building from components - (2007-08-16)
  [1195] Regular Express Primer - (2007-05-20)
  [987] Ruby v Perl - interpollating variables - (2006-12-15)
  [986] puts - opposite of chomp in Ruby - (2006-12-15)
  [970] String duplication - x in Perl, * in Python and Ruby - (2006-12-07)

Z203 - Cat and Dog
  [4189] Who are we - Lisa, Graham, Gypsy and Billy - (2013-10-07)
  [4180] Exceptionally, I sign a petition - on a life and death issue for Irish dogs - (2013-09-20)
  [4130] Soft furnishings up a Welsh Mountain - (2013-07-03)
  [4016] Red, yellow, green or pink dog? Yellow Dog Project - (2013-02-23)
  [3943] With us for a year already! - (2012-12-03)
  [3936] Lisa is home today ... - (2012-11-26)
  [3920] Challenge for a photographer - (2012-11-10)
  [3908] Black dogs at Halloween - (2012-10-31)
  [3737] Postcards from Barmouth - (2012-05-20)
  [3675] Spring 2012 - (2012-03-30)
  [3674] Off to walk the dogs - (2012-03-30)
  [3625] An update on Billy the Greyhound and Gypsy the Lurcher - (2012-02-25)
  [3606] Gypsy and Billy enjoy the snow - (2012-02-10)
  [3561] Happy Christmas ... a Christmas morning walk in Melksham - (2011-12-25)
  [3553] Changes to morning routines - (2011-12-16)
  [3541] I loves Melksham - (2011-12-06)
  [3537] Letting the foster parents know ... too little or too much? - (2011-12-04)
  [3533] No message - just doggy pictures of the new doggy - (2011-11-30)
  [3530] A typical weekend?? - (2011-11-28)
  [3338] Return trip - Dogs Trust, Newbury - (2011-06-27)
  [3324] Rabbit Shelter - (2011-06-12)
  [3096] Contrast in pictures - (2010-12-20)
  [2897] The Land of the Black Labrador - (2010-08-01)
  [2787] Sleeping in on Sunday - (2010-05-30)
  [2689] Can my dog eat potatoes? Doggie Dietary Research, and political sleaze! - (2010-03-23)
  [2555] Bookkeeping - (2009-12-29)
  [2499] ourdog is Greyhound, Staffie and Ginger Cake - (2009-11-09)
  [2496] A better design of mouth - (2009-11-07)
  [2456] Bright Eyes - (2009-10-16)
  [2451] Gypsy says - (2009-10-12)
  [2450] Family Gathering at 404, The Spa - (2009-10-11)
  [2271] Dogs Trust, Dog Show, Newbury - (2009-07-06)
  [2252] Leaping dog, Leaping horse, copyright of old masters - (2009-06-20)
  [2167] Watching the tele - (2009-05-10)
  [2140] Beware - giving copyright away when you upload a picture - Dogs Trust - (2009-04-25)
  [2138] Ski bore ... train bore ... dog bore - (2009-04-24)
  [2132] Learning about Lurchers - (2009-04-18)
  [2029] Also for the eyes of the cat - (2009-02-07)
  [771] From cat breeder to Cobol to Perl - (2006-06-21)
  [744] We can offer a room, but we can't operate on a dog - (2006-06-05)
  [547] Taking the dog for a walk - (2005-12-29)
  [96] Variable Scope - (2004-10-22)
  [62] Technical Open House - (2004-09-25)


Back to
Can you learn to program in 4 days?
Previous and next
or
Horse's mouth home
Forward to
Variable scope - what is it, and how does it Ruby?
Some other Articles
How much space does my directory take - Linux
Melksham Carnival Parade - the people
Standing on the corner, Melksham Carnival
Variable scope - what is it, and how does it Ruby?
The dog is not in trouble
Can you learn to program in 4 days?
Object Orientation in Ruby - intermediate examples
Collection objects (array and hash) in Ruby
Opening and reading files - the ruby fundamentals
4285 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2295_The ... ouble.html • PAGE BUILT: Sun Mar 30 15:20:58 2014 • BUILD SYSTEM: WomanWithCat