From 383b5fe9374f580ef2d1eb3a450cb8b755ad54d4 Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Sun, 23 Oct 2022 21:08:22 -0700 Subject: Migrate contributors to static html --- people.json | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 people.json (limited to 'people.json') diff --git a/people.json b/people.json new file mode 100644 index 0000000..cc5e8e3 --- /dev/null +++ b/people.json @@ -0,0 +1,172 @@ +[ + { + "github": "adirar111", + "name": "Aymen Dirar", + "title": "BSc Student, UBC", + "entries": [ + { + "name": "y86", + "link": "./entries/adirar111/y86/fib.s" + } + ] + }, + { + "github": "braxtonhall", + "name": "Braxton Hall", + "title": "MSc, UBC", + "entries": [ + { + "name": "express", + "link": "./entries/braxtonhall/express/index.js" + }, + { + "name": "homework", + "link": "./entries/braxtonhall/homework/fib.cpp" + }, + { + "name": "types", + "link": "./entries/braxtonhall/types/index.ts" + } + ] + }, + { + "github": "ionathanch", + "name": "Jonathan Chan", + "title": "MSc, UBC", + "entries": [ + { + "name": "agda", + "link": "./entries/ionathanch/Fib.agda" + }, + { + "name": "fortran", + "link": "./entries/ionathanch/fib.f90" + } + ] + }, + { + "github": "funemy", + "name": "Yanze Li", + "title": "PhD Student, UBC", + "entries": [ + { + "name": "agda", + "link": "./entries/funemy/agda/fib1.agda" + }, + { + "name": "z3", + "link": "./entries/funemy/z3/z3fib.sh" + } + ] + }, + { + "github": "jyoo980", + "name": "James Yoo", + "title": "MSc, UBC", + "entries": [ + { + "name": "scala", + "link": "./entries/jyoo980/scala/Fib.scala" + } + ] + }, + { + "github": "margoseltzer", + "name": "Margo Seltzer", + "title": "Professor of Computer Science, UBC", + "entries": [ + { + "name": "efficiency", + "link": "./entries/margoseltzer/efficiency.c" + } + ] + }, + { + "github": "meghasinghania22", + "name": "Megha Singhania", + "title": "BSc, UBC", + "entries": [ + { + "name": "bash", + "link": "./entries/meghasinghania22/bash/script.sh" + } + ] + }, + { + "github": "Metroxe", + "name": "Christopher Powroznik", + "title": "BCom, UBC", + "entries": [ + { + "name": "html", + "link": "./entries/Metroxe/index.html" + } + ] + }, + { + "github": "nritschel", + "name": "Nico Ritschel", + "title": "PhD Student, UBC", + "entries": [ + { + "name": "fib-java", + "link": "./entries/nritschel/fib-java/src" + } + ] + }, + { + "github": "perryliao", + "name": "Perry Liao", + "title": "BSc, UBC", + "entries": [ + { + "name": "groovy", + "link": "./entries/perryliao/fib.groovy" + } + ] + }, + { + "github": "rtholmes", + "name": "Reid Holmes", + "title": "Associate Professor of Computer Science, UBC", + "entries": [ + { + "name": "stack-overflow", + "link": "./entries/rtholmes/Fibonacci%20series%20in%20JavaScript%20-%20Stack%20Overflow.webloc" + } + ] + }, + { + "github": "shayanh", + "name": "Shayan Hosseini", + "title": "MSc Student, UBC", + "entries": [ + { + "name": "matrix", + "link": "./entries/shayanh/matrix.go" + } + ] + }, + { + "github": "Tarcisio-Teixeira", + "name": "Tarcísio Teixeira", + "title": "MSc Student, UBC", + "entries": [ + { + "name": "logn?", + "link": "./entries/Tarcisio-Teixeira/fib.py" + } + ] + }, + { + "github": "wilbowma", + "name": "William Bowman", + "title": "Assistant Professor of Computer Science, UBC", + "entries": [ + { + "name": "fib-lang", + "link": "https://github.com/wilbowma/fib-lang/tree/2ec2d1dfd141220882d824cf3dac5b374ed291f3" + } + ] + } +] \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 885f01dfdfa610acf067dc15c2ebb22b7307733e Mon Sep 17 00:00:00 2001 From: Aymen Dirar Date: Sun, 23 Oct 2022 23:10:46 -0700 Subject: update `people.json` --- people.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'people.json') diff --git a/people.json b/people.json index cc5e8e3..acdc4b2 100644 --- a/people.json +++ b/people.json @@ -7,6 +7,10 @@ { "name": "y86", "link": "./entries/adirar111/y86/fib.s" + }, + { + "name": "wasm", + "link": "./entries/adirar111/wasm/fib.wat" } ] }, @@ -169,4 +173,4 @@ } ] } -] \ No newline at end of file +] -- cgit v1.2.3-70-g09d2 From dcf99fd7ebf54474ea6d81ced6e00c28fba614fa Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Mon, 24 Oct 2022 08:48:36 +0200 Subject: add maude & ATS --- entries/lizard-business/fib.dats | 25 +++++++++++++++++++++++++ entries/lizard-business/fib.maude | 27 +++++++++++++++++++++++++++ people.json | 15 +++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 entries/lizard-business/fib.dats create mode 100644 entries/lizard-business/fib.maude (limited to 'people.json') diff --git a/entries/lizard-business/fib.dats b/entries/lizard-business/fib.dats new file mode 100644 index 0000000..f6bd5a1 --- /dev/null +++ b/entries/lizard-business/fib.dats @@ -0,0 +1,25 @@ +#include "share/atspre_define.hats" +#include "share/atspre_staload.hats" + +dataprop is_fib(int, int) = +| F0(0, 0) | F1(1, 1) +| {i, m, n : nat} Fplus(i + 2, m + n) of (is_fib(i, m), is_fib(i + 1, n)) + +typedef fib(i : int) = [n : nat] (is_fib(i, n) | int(n)) + + +fun fib {t : nat} .<>. (t : int(t)) :<> fib(t) = +let + fun go {m, n, i : nat | i <= t} .. + (M : is_fib(i, m), N : is_fib(i + 1, n) | + m : int(m), n : int(n), i : int(i)) :<> + fib(t) = + if i = t then (M | m) + else go(N, Fplus(M, N) | n, m + n, i + 1) +in + go(F0, F1 | 0, 1, 0) +end + +fun fib_(i : Nat) : Nat = let val (_ | res) = fib(i) in res end + +implement main0 () = println!("fib(15) = ", fib_(15)) diff --git a/entries/lizard-business/fib.maude b/entries/lizard-business/fib.maude new file mode 100644 index 0000000..20bc428 --- /dev/null +++ b/entries/lizard-business/fib.maude @@ -0,0 +1,27 @@ +smod FIB is + pr LIST{Nat} . + + vars M N : Nat . + var Ns : List{Nat} . + + rl [start]: nil => 0 1 . + rl [next]: Ns M N => Ns M N (M + N) . + rl [drop] : Ns N => N . + + strats fib fibgo : Nat @ List{Nat} . + sd fib(N) := start ; fibgo(N) . + sd fibgo(0) := top(drop) . + sd fibgo(s(N)) := top(next) ; fibgo(N) . +endsm + +***( + Maude> srew nil using fib(10) . + srewrite in FIB : nil using fib(10) . + + Solution 1 + rewrites: 8330 in 12ms cpu (12ms real) (694166 rewrites/second) + result NzNat: 89 + + No more solutions. + rewrites: 8469 in 12ms cpu (13ms real) (705750 rewrites/second) +) diff --git a/people.json b/people.json index cc5e8e3..526da06 100644 --- a/people.json +++ b/people.json @@ -70,6 +70,21 @@ } ] }, + { + "github": "lizard-business", + "name": "rhiannon morris", + "title": "amateur type system liker", + "entries": [ + { + "name": "maude", + "link": "./entries/lizard-business/fib.maude" + }, + { + "name": "ats", + "link": "./entries/lizard-business/fib.dats" + } + ] + }, { "github": "margoseltzer", "name": "Margo Seltzer", -- cgit v1.2.3-70-g09d2 From d642394b47cadfa4003369c8e0d2c828c9091bb8 Mon Sep 17 00:00:00 2001 From: Felipe Bañados Schwerter Date: Mon, 24 Oct 2022 10:48:14 -0600 Subject: Added fbanados --- people.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'people.json') diff --git a/people.json b/people.json index 248c644..2b78064 100644 --- a/people.json +++ b/people.json @@ -187,5 +187,16 @@ "link": "https://github.com/wilbowma/fib-lang/tree/2ec2d1dfd141220882d824cf3dac5b374ed291f3" } ] - } + }, + { + "github": "fbanados", + "name": "Felipe Bañados Schwerter", + "title": "PhD Candidate, UBC", + "entries": [ + { + "name": "coq", + "link": "./entries/fbanados/fib.v" + } + ] + }, ] -- cgit v1.2.3-70-g09d2 From bd22843d89bbf1966aca51f5b81f44f5d6766b1b Mon Sep 17 00:00:00 2001 From: Felipe Bañados Schwerter Date: Mon, 24 Oct 2022 11:28:47 -0600 Subject: Fixed people --- people.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'people.json') diff --git a/people.json b/people.json index 2b78064..dc0453e 100644 --- a/people.json +++ b/people.json @@ -198,5 +198,5 @@ "link": "./entries/fbanados/fib.v" } ] - }, + } ] -- cgit v1.2.3-70-g09d2 From 3f2544bf59ebd4839a6e545cd067a4e0c8cb349a Mon Sep 17 00:00:00 2001 From: Felipe Bañados Schwerter Date: Mon, 24 Oct 2022 11:35:21 -0600 Subject: Added second entry --- people.json | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'people.json') diff --git a/people.json b/people.json index dc0453e..2543c07 100644 --- a/people.json +++ b/people.json @@ -196,6 +196,10 @@ { "name": "coq", "link": "./entries/fbanados/fib.v" + }, + { + "name": "pharo-smalltalk", + "link": "./entries/fbanados/fib.st" } ] } -- cgit v1.2.3-70-g09d2 From f540b8058f8ed83c9230662f9d02fad898da008e Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Mon, 24 Oct 2022 14:12:11 -0400 Subject: Added fib in befunge --- entries/laelath/fib.bf | 3 +++ people.json | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 entries/laelath/fib.bf (limited to 'people.json') diff --git a/entries/laelath/fib.bf b/entries/laelath/fib.bf new file mode 100644 index 0000000..ff7d67a --- /dev/null +++ b/entries/laelath/fib.bf @@ -0,0 +1,3 @@ +>101p011p&:v:-1 < + v+g11g10_11g.@ + >11g01p11p ^ diff --git a/people.json b/people.json index 2543c07..26dc1db 100644 --- a/people.json +++ b/people.json @@ -202,5 +202,16 @@ "link": "./entries/fbanados/fib.st" } ] + }, + { + "github": "laelath", + "name": "Justin Frank", + "title": "PhD Student, UMD", + "entries": [ + { + "name": "befunge", + "link": "./entries/laelath/fib.bf" + } + ] } ] -- cgit v1.2.3-70-g09d2 From 7972ad88012a56f6afd54ada46cd45206418682a Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Mon, 24 Oct 2022 12:03:21 -0700 Subject: Add Nico's new fibs --- entries/nritschel/assets/scratch.png | Bin 0 -> 752302 bytes entries/nritschel/scratch/README.md | 1 + entries/nritschel/scratch/fib.sb3 | Bin 0 -> 43364 bytes entries/nritschel/xlsx/fib.xlsx | Bin 0 -> 11704 bytes people.json | 8 ++++++++ 5 files changed, 9 insertions(+) create mode 100644 entries/nritschel/assets/scratch.png create mode 100644 entries/nritschel/scratch/README.md create mode 100644 entries/nritschel/scratch/fib.sb3 create mode 100644 entries/nritschel/xlsx/fib.xlsx (limited to 'people.json') diff --git a/entries/nritschel/assets/scratch.png b/entries/nritschel/assets/scratch.png new file mode 100644 index 0000000..5883245 Binary files /dev/null and b/entries/nritschel/assets/scratch.png differ diff --git a/entries/nritschel/scratch/README.md b/entries/nritschel/scratch/README.md new file mode 100644 index 0000000..e059267 --- /dev/null +++ b/entries/nritschel/scratch/README.md @@ -0,0 +1 @@ +scratch preview \ No newline at end of file diff --git a/entries/nritschel/scratch/fib.sb3 b/entries/nritschel/scratch/fib.sb3 new file mode 100644 index 0000000..a3cf2cc Binary files /dev/null and b/entries/nritschel/scratch/fib.sb3 differ diff --git a/entries/nritschel/xlsx/fib.xlsx b/entries/nritschel/xlsx/fib.xlsx new file mode 100644 index 0000000..e1b662d Binary files /dev/null and b/entries/nritschel/xlsx/fib.xlsx differ diff --git a/people.json b/people.json index 26dc1db..fa3f624 100644 --- a/people.json +++ b/people.json @@ -130,6 +130,14 @@ { "name": "fib-java", "link": "./entries/nritschel/fib-java/src" + }, + { + "name": "xlsx", + "link": "./entries/nritschel/xlsx/fib.xlsx" + }, + { + "name": "scratch", + "link": "./entries/nritschel/scratch" } ] }, -- cgit v1.2.3-70-g09d2 From 06ad8853e86b5c270f31f6d7b99081323f2f677a Mon Sep 17 00:00:00 2001 From: Zack Grannan Date: Mon, 24 Oct 2022 12:02:15 -0700 Subject: Add submission for zgrannan --- entries/zgrannan/Fib.hs | 18 ++++++++++++++++++ people.json | 11 +++++++++++ 2 files changed, 29 insertions(+) create mode 100644 entries/zgrannan/Fib.hs (limited to 'people.json') diff --git a/entries/zgrannan/Fib.hs b/entries/zgrannan/Fib.hs new file mode 100644 index 0000000..1918fc8 --- /dev/null +++ b/entries/zgrannan/Fib.hs @@ -0,0 +1,18 @@ +-- Point-less fibonacci +fib :: Int -> Int +fib = fix fib' + where + fib' = + ap (when 0 . (0 ==)) . + ap (when 1 . (1 ==)) . + ap (ap . ((+) .) . (. subtract 1)) (. subtract 2) + + when t c e = if c then t else e + + ap mf m = mf >>= (\f -> m >>= return . f) + + fix f = f (fix f) + + +main :: IO () +main = mapM_ (print . fib) [0 .. 10] diff --git a/people.json b/people.json index 26dc1db..a9d5fa0 100644 --- a/people.json +++ b/people.json @@ -213,5 +213,16 @@ "link": "./entries/laelath/fib.bf" } ] + }, + { + "github": "zgrannan", + "name": "Zack Grannan", + "title": "MS Student, UBC", + "entries": [ + { + "name": "haskell", + "link": "./entries/zgrannan/Fib.hs" + } + ] } ] -- cgit v1.2.3-70-g09d2 From a9e39fa02410b61288208509e038b9e096486702 Mon Sep 17 00:00:00 2001 From: Zack Grannan Date: Mon, 24 Oct 2022 12:13:14 -0700 Subject: Update designation --- people.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'people.json') diff --git a/people.json b/people.json index a9d5fa0..cd0cb50 100644 --- a/people.json +++ b/people.json @@ -217,7 +217,7 @@ { "github": "zgrannan", "name": "Zack Grannan", - "title": "MS Student, UBC", + "title": "MSc Computer Science Student, UBC", "entries": [ { "name": "haskell", -- cgit v1.2.3-70-g09d2 From 0aa0d695f8fef33b02cbf04fbd6825bd2cbc6de1 Mon Sep 17 00:00:00 2001 From: Xu, Junfeng Date: Mon, 24 Oct 2022 12:24:50 -0700 Subject: add haskell entry --- entries/nxjfxu/fib.hs | 5 +++++ people.json | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 entries/nxjfxu/fib.hs (limited to 'people.json') diff --git a/entries/nxjfxu/fib.hs b/entries/nxjfxu/fib.hs new file mode 100644 index 0000000..0f0d871 --- /dev/null +++ b/entries/nxjfxu/fib.hs @@ -0,0 +1,5 @@ +fib :: Int -> Int +fib = (fibs !!) + where + fibs = 0 : 1 : [fibs !! (i - 2) + fibs !! (i - 1) | i <- [2..]] + diff --git a/people.json b/people.json index 26dc1db..e63fc4d 100644 --- a/people.json +++ b/people.json @@ -213,5 +213,16 @@ "link": "./entries/laelath/fib.bf" } ] + }, + { + "github": "nxjfxu", + "name": "Junfeng Xu", + "title": "MSc Student, UBC", + "entries": [ + { + "name": "ouroboros", + "link": "./entries/nxjfxu/fib.hs" + } + ] } ] -- cgit v1.2.3-70-g09d2 From db535e5c3035030bc1089528ad5fc12b9eef14ad Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Mon, 24 Oct 2022 12:34:39 -0700 Subject: Add Paulette --- entries/pkoronkevich/tex/README.md | 1 + entries/pkoronkevich/tex/fib.tex | 28 ++++++++++++++++++++++++++++ entries/pkoronkevich/tex/render.pdf | Bin 0 -> 21761 bytes entries/pkoronkevich/tex/render.png | Bin 0 -> 297404 bytes people.json | 11 +++++++++++ 5 files changed, 40 insertions(+) create mode 100644 entries/pkoronkevich/tex/README.md create mode 100644 entries/pkoronkevich/tex/fib.tex create mode 100644 entries/pkoronkevich/tex/render.pdf create mode 100644 entries/pkoronkevich/tex/render.png (limited to 'people.json') diff --git a/entries/pkoronkevich/tex/README.md b/entries/pkoronkevich/tex/README.md new file mode 100644 index 0000000..225773b --- /dev/null +++ b/entries/pkoronkevich/tex/README.md @@ -0,0 +1 @@ +fib.tex preview \ No newline at end of file diff --git a/entries/pkoronkevich/tex/fib.tex b/entries/pkoronkevich/tex/fib.tex new file mode 100644 index 0000000..22781d1 --- /dev/null +++ b/entries/pkoronkevich/tex/fib.tex @@ -0,0 +1,28 @@ +\documentclass[11pt]{article} +\usepackage[fleqn]{amsmath} + +\newcommand{\one}{\lambda f . \lambda x . f \ x} +\newcommand{\two}{\lambda f . \lambda x . f \ (f \ x)} +\newcommand{\tru}{\lambda x . \lambda y . x} +\newcommand{\flse}{\lambda x . \lambda y . y} +\newcommand{\isz}{\lambda n . n \ (\lambda c . \flse) \ \tru} +\newcommand{\ife}{\lambda p . \lambda a . \lambda b . p \ a \ b} +\newcommand{\suc}{\lambda n . \lambda f . \lambda x . f \ (n \ f \ x)} +\newcommand{\plus}{\lambda m . \lambda n . m \ (\suc) \ n} +\newcommand{\pred}{\lambda n . \lambda f . \lambda x . n \ (\lambda g . \lambda h . h \ (g \ f)) \ (\lambda u . x) \ (\lambda u . u)} +\newcommand{\sub}{\lambda m . \lambda n . n \ (\pred) \ m} +\newcommand{\fix}{\lambda g . (\lambda x . g \ (x \ x)) \ (\lambda x . g \ (x \ x))} +\newcommand{\appo}[2]{#1 \ #2} +\newcommand{\appt}[3]{#1 \ #2 \ #3} + +\begin{document} +\begin{gather*} + \fix \\ % recursive function application + \quad \lambda r . \lambda n . (\ife) \\ % of fib, which takes itself and n, if expression + \quad \ \appo{(\isz)}{n} \\ % is n zero + \quad \ (\one) \\ % if so, return 1 + \quad \ (\plus) \\ % if not, add + \qquad \appo{r}{(\appo{(\pred)}{n})} \\ % the first recursive call, n - 1, to + \qquad \appo{r}{(\appt{(\sub)}{n}{\two})} % the second recursive call, n - 2 +\end{gather*} +\end{document} diff --git a/entries/pkoronkevich/tex/render.pdf b/entries/pkoronkevich/tex/render.pdf new file mode 100644 index 0000000..b69f747 Binary files /dev/null and b/entries/pkoronkevich/tex/render.pdf differ diff --git a/entries/pkoronkevich/tex/render.png b/entries/pkoronkevich/tex/render.png new file mode 100644 index 0000000..2e172cc Binary files /dev/null and b/entries/pkoronkevich/tex/render.png differ diff --git a/people.json b/people.json index b957009..ef2cbd2 100644 --- a/people.json +++ b/people.json @@ -232,5 +232,16 @@ "link": "./entries/zgrannan/Fib.hs" } ] + }, + { + "github": "pkoronkevich", + "name": "Paulette Koronkevich", + "title": "PhD Student, UBC", + "entries": [ + { + "name": "tex", + "link": "./entries/pkoronkevich/tex" + } + ] } ] -- cgit v1.2.3-70-g09d2 From 2db6cb57d86bfa3616e9f8ede8ac73b30dfe75e1 Mon Sep 17 00:00:00 2001 From: StuartLiv Date: Mon, 24 Oct 2022 14:26:31 -0700 Subject: Added ThetaFibN --- entries/StuartLiv/ThetaFibN.java | 13 +++++++++++++ people.json | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 entries/StuartLiv/ThetaFibN.java (limited to 'people.json') diff --git a/entries/StuartLiv/ThetaFibN.java b/entries/StuartLiv/ThetaFibN.java new file mode 100644 index 0000000..1e4f431 --- /dev/null +++ b/entries/StuartLiv/ThetaFibN.java @@ -0,0 +1,13 @@ +public class ThetaFibN { + + //Fibonacci(n) is asymptotically in ϴ(Fibonacci(n)) + public int Fibonacci(int n) { + String reference = "0"; + int fib = 1; + for(int i = 1; i <= n; i++) { + fib = reference.length(); + reference = reference.replace("0", "").replace("1", "0") + "1".repeat(fib); + } + return fib; + } +} diff --git a/people.json b/people.json index 248c644..bb44dde 100644 --- a/people.json +++ b/people.json @@ -166,6 +166,17 @@ } ] }, + { + "github": "StuartLiv", + "name": "Stuart Livingstone", + "title": "BSc Student, UBC", + "entries": [ + { + "name": "ThetaFibN", + "link": "./entries/StuartLiv/ThetaFibN.java" + } + ] + }, { "github": "Tarcisio-Teixeira", "name": "Tarcísio Teixeira", -- cgit v1.2.3-70-g09d2 From 8ffac10bf733f5f75bf85750562710c1cd60cf0a Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Mon, 24 Oct 2022 15:14:18 -0700 Subject: Add Ron --- entries/rxg/fib.rkt | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++ people.json | 11 +++++ 2 files changed, 143 insertions(+) create mode 100644 entries/rxg/fib.rkt (limited to 'people.json') diff --git a/entries/rxg/fib.rkt b/entries/rxg/fib.rkt new file mode 100644 index 0000000..61373cd --- /dev/null +++ b/entries/rxg/fib.rkt @@ -0,0 +1,132 @@ +#lang racket + +;; fib.rkt - A variety of iterative implementations of the Fibonacci Sequence +;; All are based on accumulators + +;; Natural -> Natural +;; produce the n'th Fibonacci number +(define (fib-iter n) + (cond + [(= n 0) 1] + [(= n 1) 1] + [else + (let-values ([(n-2 n-1) + ;; i-2 = fib (i-2) + ;; i-1 = fib (i-1) + (for/fold ([i-2 1] [i-1 1]) + ([i (in-range 2 n)]) + (values i-1 (+ i-2 i-1)))]) + (+ n-2 n-1))])) + + +(define (fib-iter2 n) + (cond + [(= n 0) 1] + [(= n 1) 1] + [else + ;; i-2 = fib (i-2) + ;; i-1 = fib (i-1) + (let loop ([i-2 1] [i-1 1] [i 2]) + (if (= i n) + (+ i-2 i-1) + (loop i-1 (+ i-2 i-1) (add1 i))))])) + +(define (fib-iter3 n) + (cond + [(= n 0) 1] + [(= n 1) 1] + [else + ;; i-2 = fib (i-2) + ;; i-1 = fib (i-1) + (do ([i-2 1 i-1] + [i-1 1 (+ i-2 i-1)] + [i 2 (add1 i)]) + [(= i n) + (+ i-2 i-1)])])) + +;; New variant of for with accumulators and a final expression in terms of +;; the accumulators +(define-syntax (for/acc stx) + (syntax-case stx () + [(_ ([id* init*] ...) + (clauses ...) + body + result) + (with-syntax ([original stx]) + #'(let-values ([(id* ...) + (for/fold/derived original + ([id* init*] ...) + (clauses ...) + body)]) + result))])) + +(define (fib-iter4 n) + (cond + [(= n 0) 1] + [(= n 1) 1] + [else + ;; i-2 = fib (i-2) + ;; i-1 = fib (i-1) + (for/acc ([i-2 1] [i-1 1]) + ([i (in-range 2 n)]) + (values i-1 (+ i-2 i-1)) + (+ i-2 i-1))])) + +;; New variant of for with accumulators and a final expression in terms of +;; the accumulators +(define-syntax (for/do stx) + (syntax-case stx () + [(_ ([id* init* step*] ...) + (clauses ...) + result) + (with-syntax ([original stx]) + #'(let-values ([(id* ...) + (for/fold/derived original + ([id* init*] ...) + (clauses ...) + (values step* ...))]) + result))])) + +(define (fib-iter5 n) + (cond + [(= n 0) 1] + [(= n 1) 1] + [else + ;; i-2 = fib (i-2) + ;; i-1 = fib (i-1) + (for/do ([i-2 1 i-1] [i-1 1 (+ i-2 i-1)]) + ([i (in-range 2 n)]) + (+ i-2 i-1))])) + + +;; Fibonacci's problem, as described by Greg Rawlins in "Compared to What": +;; Suppose you have a pair of rabbits and suppose every month each pair +;; bears a new pair that from the second month on becomes productive. +;; how many pairs of rabbits will you have in a year? + +;; Analysis: +;; - At time 0 you have 1 unproductive pair: 1 pair, 0 productive pairs +;; - Each month, each productive pair produces an unproductive pair +;; - Each month, last months unproductive pairs transition to productive +;; - how many pairs are there at time step 12? + +;; The following function solves the problem *directly* as a +;; structural recursion over natural numbers with two +;; accumulators (for lost context (fertile) and result-so-far (total)) + +;; Natural -> Natural +;; produce the solution to Fibonacci's problem after n months +(define (fib-rabbit n0) + ;; Accumulator: total is Natural + ;; Invariant: total pairs of rabbits after (- n0 n) months + ;; Accumulator: fertile is Natural + ;; Invariant: productive pairs of rabbits after (- n0 n) months + (local [(define (fib-acc fertile total n) + (cond [(zero? n) total] + [else + (fib-acc total ;; next month, all will be productive + (+ ;; next months pairs include: + total ;; - this months pairs plus + fertile) ;; - offspring from productive pairs + (sub1 n))]))] + (fib-acc 0 1 n0))) diff --git a/people.json b/people.json index b84c8d8..1ff8fa0 100644 --- a/people.json +++ b/people.json @@ -163,6 +163,17 @@ } ] }, + { + "github": "rxg", + "name": "Ronald Garcia", + "title": "Associate Professor of Computer Science, UBC", + "entries": [ + { + "name": "fib-iter*", + "link": "./entries/rxg/fib.rkt" + } + ] + }, { "github": "shayanh", "name": "Shayan Hosseini", -- cgit v1.2.3-70-g09d2 From d8809640625ff7113b3e534a0ddc84d970674570 Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Mon, 24 Oct 2022 15:21:37 -0700 Subject: Add Marie --- entries/MarieSal0/FibonacciWorkplace/.gitignore | 133 +++++++++++++++++++++ .../FibonacciWorkplace/FibonacciWorkplace.csproj | 10 ++ entries/MarieSal0/FibonacciWorkplace/Program.cs | 41 +++++++ people.json | 11 ++ 4 files changed, 195 insertions(+) create mode 100644 entries/MarieSal0/FibonacciWorkplace/.gitignore create mode 100644 entries/MarieSal0/FibonacciWorkplace/FibonacciWorkplace.csproj create mode 100644 entries/MarieSal0/FibonacciWorkplace/Program.cs (limited to 'people.json') diff --git a/entries/MarieSal0/FibonacciWorkplace/.gitignore b/entries/MarieSal0/FibonacciWorkplace/.gitignore new file mode 100644 index 0000000..9b956f9 --- /dev/null +++ b/entries/MarieSal0/FibonacciWorkplace/.gitignore @@ -0,0 +1,133 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.svclog +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.azurePubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +packages/ +## TODO: If the tool you use requires repositories.config, also uncomment the next line +!packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +![Ss]tyle[Cc]op.targets +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml + +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +_NCrunch* \ No newline at end of file diff --git a/entries/MarieSal0/FibonacciWorkplace/FibonacciWorkplace.csproj b/entries/MarieSal0/FibonacciWorkplace/FibonacciWorkplace.csproj new file mode 100644 index 0000000..40c60dd --- /dev/null +++ b/entries/MarieSal0/FibonacciWorkplace/FibonacciWorkplace.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/entries/MarieSal0/FibonacciWorkplace/Program.cs b/entries/MarieSal0/FibonacciWorkplace/Program.cs new file mode 100644 index 0000000..bac5688 --- /dev/null +++ b/entries/MarieSal0/FibonacciWorkplace/Program.cs @@ -0,0 +1,41 @@ +using System; +namespace FibonacciWorkplace +{ + public class Program + { + static void Main(string[] args) + { + Console.Write("How long should the Fibonacci Series be?? "); + int lengthOfSeries = Convert.ToInt32(Console.ReadLine()); + if (lengthOfSeries<=2) + { + LengthCheck(lengthOfSeries); + } + FibonacciSeries(0, 1, 1, lengthOfSeries); + Console.ReadKey(); + } + public static void LengthCheck(int lengthOfSeries) + { + if (lengthOfSeries<=1) + { + Console.Write("The Fibonacci Series needs to be greater than 2"); + lengthOfSeries = Convert.ToInt32(Console.ReadLine()); + LengthCheck(lengthOfSeries); + } + + } + + public static void FibonacciSeries(int firstNumber, int secondNumber, int counter, int lengthOfSeries) + { + Console.Write(firstNumber + " "); + if (counter < lengthOfSeries) + { + int sum = firstNumber + secondNumber; + counter++; + FibonacciSeries(secondNumber, sum, counter, lengthOfSeries); + } + } + + + } +} \ No newline at end of file diff --git a/people.json b/people.json index b84c8d8..60654a5 100644 --- a/people.json +++ b/people.json @@ -100,6 +100,17 @@ } ] }, + { + "github": "MarieSal0", + "name": "Marie Salomon", + "title": "MSc Student, UBC", + "entries": [ + { + "name": "c#", + "link": "./entries/MarieSal0/FibonacciWorkplace/Program.cs" + } + ] + }, { "github": "meghasinghania22", "name": "Megha Singhania", -- cgit v1.2.3-70-g09d2