(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* :Name: PwM`Chap02Language` *)


(* :Book: Programming with Mathematica: An Introduction *)


(* :Author: Paul Wellin *)


(* :Summary: This package contains the functions defined in Chapter 2, The Mathematica language. *)


(* :Context: PwM`Chap02Language` *)


(* :Package Version: 1.0 *)


(* :Copyright: Copyright 2012, Cambridge University Press *)


(* :History: Version 1.0 by Paul Wellin, Dec 2012 *)


(* :Keywords: string characters, composite numbers, natural numbers, subsets. *)


(* :Source: Chap02Language.nb *)


(* :Mathematica Version: 8.0.4 *)


Remove[CompositeQ]


BeginPackage["PwM`Chap02Language`"]


CharacterQ::usage="Character[\!\(\*
StyleBox[\"c\", \"TI\"]\)] returns True if \!\(\*
StyleBox[\"c\", \"TI\"]\) is a string of length one.";


CompositeQ::usage="CompositeQ[\!\(\*
StyleBox[\"n\", \"TI\"]\)] returns True if \!\(\*
StyleBox[\"n\", \"TI\"]\) is a composite number.";


NaturalQ::usage="NaturalQ[\!\(\*
StyleBox[\"n\", \"TI\"]\)] returns True if \!\(\*
StyleBox[\"n\", \"TI\"]\) is a natural number.";


SubsetQ::usage="SubsetQ[\!\(\*SubscriptBox[
StyleBox[\"lis\", \"TI\"], \(1\)]\),\!\(\*SubscriptBox[
StyleBox[\"lis\", \"TI\"], \(2\)]\)] returns True if \!\(\*SubscriptBox[
StyleBox[\"lis\", \"TI\"], \(1\)]\) is a subset of \!\(\*SubscriptBox[
StyleBox[\"lis\", \"TI\"], \(2\)]\).";


Begin["`Private`"]


CharacterQ[ch_]:=StringQ[ch]&&StringLength[ch]==1


NaturalQ[n_]:=IntegerQ[n]&&n>=0


SubsetQ[{},lis2_]:=True


SubsetQ[lis1_,lis2_]:=Intersection[lis1,lis2]==lis1


lis1_\[Subset]lis2_:=Intersection[lis1,lis2]==lis1


CompositeQ[n_Integer/;n>1]:=Not[PrimeQ[n]]


End[]


EndPackage[]



