This is licenced same as SDF book using Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License since most of my codes are based on the course code base and the book.
I don't know whether it is appropriate. If it is inappropriate and someone knows detailedly about the difference among licences, please tell me the appropriate choice.
- 2.14
- I tried to find one possible example to implement in https://martinfowler.com/dsl.html#:~:text=Domain%2Dspecific%20languages%20have%20been,strut's%20configuration%20file.... but only "ant" and "graphviz's dot language" seem to be implement as one demo. But the former is related with Java and the latter is related with drawing one graph.
- "salary calculation" in this doesn't have one general model.
- After all, this exercise is more about how we think about a domain and then program it.
IMHO checkers and then manual implementation of chess are enough.
- "domain model" as SDF_notes.md shows is about "abstract types".
- 3.6-c.
- 3.22-b.
- Sometimes, I only give one sample test since I didn't intend to learn how to write the safe tests.
- I use naming with
_
instead of-
since words constructed with the former can be selected in VSCode with the double clicks. - solution comment also see codes.
- Here I use the absolute path like
(load "~/SICP_SDF/SDF_exercises/software/sdf/abstracting-a-domain/game-interpreter.scm")
to make we can callscheme < foo.scm
in any dir. You can usesed
etc. to change this. - All exercise solutions will be given related tests. But obviously I won't ensure the test must promise the solution is correct since there is no such a test (Correctness should be proved by maths).
- checking whether it is appropriate to use
eq?
orequal?
etc. for each case. (so same formemv
, etc.) - tests of sample implementations.
- SDF_exercises TODO
- sci-42ver/SDF_exercise_solution
exercise solution for Software Design for Flexibility (SDF)
"Software Design for Flexibility exercise solution" and "Software Design for Flexibility exercise solution gitlab" (almost nothing related) or "... github" both doesn't have more related links with exercises.
- partial
This is one repo with solutions to some exercises although too less.
This has partial solutions by this search although without appropriate tests.
This
I can't find the relation with the exercisesgives partial solution in Racket based on chapter. (This seems to be the most detailed one) ~~ https://github.com/chebert/software-design-for-flexibility/blob/5eacde59855888180482031b9ee27c7c7b6cf4d1/sdf-function-combinators.rkt#L110-L111 implies it doesn't solve the exercise at all.~~Since it uses something likearity-at-least?
, it will take unnecessary time to check Racket doc. So I won't read this implementation except when I am really stuck at something.thishas no solutions as README says.
- See this with annotations from this
summary
- The above seems to have no solutions for Assignment by searching "Assignment".
- I can't join its slack room and this course has finished
this havinghttps://github.com/compclub/exercises/blob/main/chapter-2-dsl/rmoehn/README.mdthe mostpartial solutions although with full chapter dir's ... uses ClojureI'm not completing most of the exercises, since I assume the initial thinking about the solution is the most valuable part for me. Weird man. So so I might end up fooling myself.
thisuses Rust...https://github.com/bishwa-poudel/Software-Design-and-Architecture-Specialization-Courseraweirdly use Java.
@exercise solutions by 3 references (i.e. nbardiuk etc.) and 6.945_assignment_solution checked up to now (sometimes code base has sample implementations)
with check comments in codes.
- 2, 3.1~3.22
- 2, 3.1~3.22
- I skipped checking the detailed implementation of the following since they are less related with what the book intends to teach
make-predicate-template
(not shown in the SDF book. There is no related funcs even by searching "template") So I skipped checkingSDF_exercises/software/sdf/user-defined-types/vector-arith.scm
(user-defined-types/vector-arith).define-generic-procedure-extractor
(not shown in the SDF book. There is no related funcs even by searching "extractor")
- From cc09d5b919575d7a27d30d94100d2f12dd8248ef up to .
By https://github.com/search?q=repo%3Anbardiuk%2Fsoftware-design-for-flexibility%20exercise&type=code it probably only has 3 exercise solutions.
It only have solutions up to chapter 2 regular-expressions based on 5 filenames.
-
; (assert (= 2 (get-arity h))) this is too naive - does not allow to use 'list Not. Since if this holds, then
(assert (= 1 f-arity))
also doesn't work.
(guarantee-procedure-of-arity h (make-procedure-arity 2) 'h)
impliesh
can have more than 2 arguments.
- totally independent from 2.1~2 without any assertion.
call-with-values
the continuation expects to receive the same number of values that procedure accepts as arguments. Thunk must return multiple values using the values procedure. Then procedure is called with the multiple values as its arguments. The result yielded by procedure is returned as the result of call-with-values This implies
compose
. Thunk is invoked with a continuation that expects to receive multiple values; i.e. what it does will "receive multiple values" as(apply g args)
implies. See https://www.gnu.org/software/guile/manual/html_node/Continuations.html- TODO '"multiple-value" continuation'
The following is more general than mine since it allow the case where f has variable argument number and g has the fixed argument number.
(assert (or (fixed-arity? arity-f)
(fixed-arity? arity-g)))
2.4
It seems to have no test files by searching "r:seq" with only 1 result file.
combine-arities
is a bit different due toarity-list
.
- without any assertion same as nbardiuk.
- 2.7
-
(ere expr) or (bre expr) multiple references ...
-
- Use
((lambda (x) x) (values 1 2))
to show whatvalues
returns. reduce
difffold
kw: "right identity"Note that ridentity is used only in the empty-list case.
-
you’d like to avoid the extra application incurred when fold applies f to the head of list and the identity value i.e. return (fold f (car list) (cdr list)). But this just decreases only one operation.
-
-
If multiple returns occur from map, the values returned by earlier returns are not mutated. https://www.gnu.org/software/mit-scheme/documentation/stable/mit-scheme-ref/Mapping-of-Lists.html Does it mean https://groups.google.com/g/comp.lang.scheme/c/ruhDvI9utVc/m/jS0DdIh2yKMJ? Then what does "earlier returns" mean?
-
However, in cases where this ambiguity can arise, you should use find-tail instead of find—find-tail has no such ambiguity: IMHO both "no such pair" and "doesn’t find such an element" will occur.
- The following are both undefined in saved-total-index and MIT_Scheme_Reference.
- list-of-unique-symbols?
- list-of-type?
- maybe mean a list of data whose type satisfies
pred
by(list-of-type? object change?)
.
- maybe mean a list of data whose type satisfies
- 2.9
- POSIX_regex
The string matched by a contained subexpression shall be within the string matched by the containing subexpression. If the containing subexpression does not match, or if there is no match for the contained subexpression within the string matched by the containing subexpression, then back-reference expressions corresponding to the contained subexpression shall not match. See "the expression "(a(b))\2" fails to match 'abab'" where b must correspond to "\2", then "aba" can be matched to "the containing subexpression". When a subexpression matches more than one string, a back-reference expression corresponding to the subexpression shall refer to the last matched string. See "the expression "^(ab*)*\1$" matches 'ababbabb', but fails to match 'ababbab'." where the last "abb" is matched to "\1".
- POSIX_regex
- 2.10
- 2.12
- check the rules intuitively by manual playing for 2 players https://www.chessmultiplayer.com/
-
Don't try to implement the castling rule. we need to check 3 conditions in wikipedia if to implement it. a. "must not have previously moved"
can be checked by flag.b. "There must be no pieces between the king and the rook;" can be checked by inspecting position-info between them c. "The king may not currently be ..." i.e. call check for all related positions. d. "The castling must be kingside or queenside" since they are the only 2 possible cases. - All rules are based on https://en.wikipedia.org/wiki/Rules_of_chess#Touch-move_rule
- Here I won't check
- "Competitive rules of play", i.e. FIDE rules.
- "Touch-move rule" and "Resigning" since these depends on artifical interposition.
- IGNORE
- (see the following)
We need to checkIt is illegal to make a move that places or leaves one's king in check.
- so also Checkmate
- (see "castling".)
3. Check similar torequire-jumps
: If failure, then Checkmate- So we also won't check "stalemate", then combined with "Dead position" we won't check "draw".
- due to the very hardness of implementation
Dead positionskipped due to the possible huge combination number (man_1_options * man_2_options * man_1_options_currect ...
infinitely recursion) and we must check it after each iteration.by any sequence of legal moves. even if we don't consider the complexity overhead, the correct algorithm is not easy https://chess.stackexchange.com/a/22764.
- https://chess.stackexchange.com/a/22557 doesn't say any valuable but just show possibility ...
- TODO I can't see such a comments for "in the comments user17439".
- https://chess.stackexchange.com/a/22557 doesn't say any valuable but just show possibility ...
- (see the following)
- what to do beyond "Basic moves"
- Promotion is trivial by checking the type and position (similar to
should-be-crowned?
)
- Promotion is trivial by checking the type and position (similar to
- En passant: check adjacent piece "on the same rank"
whether with flag "advances two squares on its initial move"(only on the move immediately following the pawn's advance) and type "pawn".- I won't check it since pawn can either advance one square twice or advance "two squares" once. "flag" is associated with
pmove
which won't be remembered for later usage. IMHO the best solution is to add flag with piece but the interface forpiece
will be all changed.- Here whether we can remember history steps is also needed in "castling" to test
The king and rook involved in castling must not have previously moved
- Here whether we can remember history steps is also needed in "castling" to test
- I won't check it since pawn can either advance one square twice or advance "two squares" once. "flag" is associated with
- Here I won't check
- notice
after checking https://en.wikipedia.org/wiki/Rules_of_chess#Basic_moves preface
The king can be put in check but cannot be captured (see below).
- chebert
- check castling
- by adding types. (also used for other special moves)
- check castling
- See 3_3.scm "(only nbardiuk repo is not included in this repo)" but it only have chapter 2 implementation.
- mbillingr
only has automatic-differentiation.has nothing. - by
grep "generic" -r .
chebert has nothing for chapter 3 after 3.2 (included). Then by searching keywords likevec-before-func
in exercise 3.1~3.3, it also have no implementations for these. - 6.945_assignment_solution
- ps03 has 3.2, 3.5, 3.6, 3.7, 4.0 although they are not same as 2024 version.
- ps04 only has one similar implementation of Exercise 3.16.
- 2
- 11
- [111] reference
TODO why(D (λy . x + y) 1)
doesn't calculate derivative and gets 2.
- [111] reference