http://hg.viff.dk/viff/rev/88ac6ac5fe70
changeset: 1107:88ac6ac5fe70
user: Tord Reistad <[email protected]>
date: Thu Mar 05 13:00:59 2009 +0100
summary: Utility function for if_then that works with shares.
diffstat:
1 file changed, 10 insertions(+)
viff/util.py | 10 ++++++++++
diffs (20 lines):
diff -r ab726c059750 -r 88ac6ac5fe70 viff/util.py
--- a/viff/util.py Fri Feb 20 10:20:34 2009 +0100
+++ b/viff/util.py Thu Mar 05 13:00:59 2009 +0100
@@ -388,6 +388,16 @@
for key, value in usage.iteritems()])
_last_memory_usage = usage
+def if_then(cond, a, b):
+ """If then else operator works both for integers and for shares.
+
+ >>> if_then(0, 3, 6)
+ 6
+ >>> if_then(1, 3, 6)
+ 3
+ """
+ return b + cond * (a - b)
+
if __name__ == "__main__":
import doctest #pragma NO COVER
doctest.testmod() #pragma NO COVER
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk