# [LON-CAPA-cvs] cvs: rat / lonuserstate.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 22 Feb 2006 21:59:00 -0000

```albertel		Wed Feb 22 16:59:00 2006 EDT

Modified files:
/rat	lonuserstate.pm
Log:
- elminating a regexp that does little but take a long time to do it
- the 0th condition is by definition always true

Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.100 rat/lonuserstate.pm:1.101
--- rat/lonuserstate.pm:1.100	Fri Feb 10 17:33:42 2006
+++ rat/lonuserstate.pm	Wed Feb 22 16:58:59 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Construct and maintain state and binary representation of course for user
#
-# \$Id: lonuserstate.pm,v 1.100 2006/02/10 22:33:42 albertel Exp \$
+# \$Id: lonuserstate.pm,v 1.101 2006/02/22 21:58:59 albertel Exp \$
#
# Copyright Michigan State University Board of Trustees
#
@@ -318,6 +318,8 @@

sub simplify {
my \$expression=shift;
+# (0&1) = 1
+    \$expression=~s/\(0\&(\d+)\)/\$1/g;
# (8)=8
\$expression=~s/\((\d+)\)/\$1/g;
# 8&8=8
@@ -327,8 +329,8 @@
# (5&3)&4=5&3&4
\$expression=~s/\((\d+)((?:\&\d+)+)\)\&(\d+\D)/\$1\$2\&\$3/g;
# (((5&3)|(4&6)))=((5&3)|(4&6))
-    \$expression=~
-	s/\((\(\(\d+(?:\&\d+)*\)(?:\|\(\d+(?:\&\d+)*\))+\))\)/\$1/g;
+#    \$expression=~
+#	s/\((\(\(\d+(?:\&\d+)*\)(?:\|\(\d+(?:\&\d+)*\))+\))\)/\$1/g;
# ((5&3)|(4&6))|(1&2)=(5&3)|(4&6)|(1&2)
\$expression=~
s/\((\(\d+(?:\&\d+)*\))((?:\|\(\d+(?:\&\d+)*\))+)\)\|(\(\d+(?:\&\d+)*\))/\(\$1\$2\|\$3\)/g;

```