Prechádzať zdrojové kódy

Update examples in book

David Peter 2 rokov pred
rodič
commit
deda3fe26c

+ 1 - 1
book/build.sh

@@ -27,7 +27,6 @@ generate_example() {
 }
 
 generate_example medication_dosage "Medication dosage" true
-generate_example workhours "Workhours" true
 generate_example barometric_formula "Barometric formula" true
 generate_example molarity "Molarity" true
 generate_example musical_note_frequency "Musical note frequency" true
@@ -36,6 +35,7 @@ generate_example pipe_flow_rate "Flow rate in a pipe" true
 generate_example recipe "Recipe" true
 generate_example acidity "Acidity" true
 generate_example factorial "Factorial" false
+generate_example xkcd_687 "XKCD 687" true
 generate_example xkcd_2585 "XKCD 2585" true
 generate_example xkcd_2812 "XKCD 2812" true
 

+ 6 - 6
book/src/SUMMARY.md

@@ -5,16 +5,16 @@
 - [Introduction](./introduction.md)
 - [Tutorial](./tutorial.md)
 - [Example programs](./examples.md)
-    - [Medication dosage](./example-medication_dosage.md)
-    - [Workhours](./example-workhours.md)
+    - [Acidity](./example-acidity.md)
     - [Barometric formula](./example-barometric_formula.md)
-    - [Molarity](./example-molarity.md)
-    - [Musical note frequency](./example-musical_note_frequency.md)
     - [Body mass index](./example-body_mass_index.md)
+    - [Factorial](./example-factorial.md)
     - [Flow rate in a pipe](./example-pipe_flow_rate.md)
+    - [Medication dosage](./example-medication_dosage.md)
+    - [Molarity](./example-molarity.md)
+    - [Musical note frequency](./example-musical_note_frequency.md)
     - [Recipe](./example-recipe.md)
-    - [Acidity](./example-acidity.md)
-    - [Factorial](./example-factorial.md)
+    - [XKCD 687](./example-xkcd_687.md)
     - [XKCD 2585](./example-xkcd_2585.md)
     - [XKCD 2812](./example-xkcd_2812.md)
 

+ 2 - 0
book/src/example-xkcd_2585.md

@@ -3,6 +3,8 @@
 # XKCD 2585
 
 ``` numbat
+# Rounding
+#
 # https://xkcd.com/2585/
 
 17 mph

+ 19 - 0
book/src/example-xkcd_687.md

@@ -0,0 +1,19 @@
+<!-- This file is autogenerated! Do not modify it -->
+
+# XKCD 687
+
+``` numbat
+# Dimensional analysis
+#
+# https://xkcd.com/687/
+
+let core_pressure = 3.5 million atmospheres
+let prius_milage = 50 miles per gallon
+let min_width_channel = 21 miles
+
+# Make sure that the result is dimensionless:
+let r: Scalar =
+    planck_energy / core_pressure × prius_milage / min_width_channel
+
+print("{r} ≈ π ?")
+```

+ 2 - 2
book/src/examples.md

@@ -1,4 +1,4 @@
 # Examples
 
-This chapter shows some exemplary Numbat programs from various scientific
-and engineering disciplines.
+This chapter shows some exemplary Numbat programs from various disciplines
+and sciences.

+ 2 - 0
examples/xkcd_2585.nbt

@@ -1,3 +1,5 @@
+# Rounding
+#
 # https://xkcd.com/2585/
 
 17 mph

+ 7 - 4
examples/xkcd_687.nbt

@@ -1,10 +1,13 @@
 # Dimensional analysis
 #
 # https://xkcd.com/687/
-#
 
-let earth_core_pressure = 3.5 million atmospheres
+let core_pressure = 3.5 million atmospheres
 let prius_milage = 50 miles per gallon
-let english_channel_min_width = 21 miles
+let min_width_channel = 21 miles
+
+# Make sure that the result is dimensionless:
+let r: Scalar =
+    planck_energy / core_pressure × prius_milage / min_width_channel
 
-print(planck_energy / earth_core_pressure * prius_milage / english_channel_min_width)
+print("{r} ≈ π ?")