lab19: init

This commit is contained in:
2026-04-29 11:33:23 -07:00
parent d042a0e016
commit dba2c2b3d6
12 changed files with 386 additions and 0 deletions

20
lab19/with-prob.rb Normal file
View File

@@ -0,0 +1,20 @@
def with_prob (prob)
yield if (Random.rand < prob)
end
with_prob 0.42 do
puts "There is a 42% chance that this code will print"
end
def foo x
with_prob 0.5 do
puts "Executing with_prob block"
return 0
end
return x
end
puts "Foo is #{foo 1}"