If you need help with programming, advice, recommendations, and so on and so on, just post here and the brightest minds of SchemeBBS will surely help you!
Does P = NP?
I want an robot AI waifu.
why is this not working??
(define (fizzbuzz n)
(cond
(zero? (remainder n 5)) 'fizz
(zero? (remainder n 3)) 'buzz
else n))
(map fizzbuzz '(1 2 3 4 5 6 7 8 9 10))
>>4
Because COND works a bit differently (it is one of the special forms): https://api.call-cc.org/5/doc/scheme/cond or https://schemers.org/Documents/Standards/R5RS/
You need to do it like this:
#!/usr/bin/guile -s
!#
;coding: utf-8
;; those 3 lines above are Guile specific stuff:
;; https://www.gnu.org/software/guile/manual/html_node/The-Top-of-a-Script-File.html
; (you can replace the square brackets with regular parenthesis)
(define (fizzbuzz n)
(cond
[(zero? (remainder n 5)) 'buzz]
[(zero? (remainder n 3)) 'fizz]
[else n]))
(map fizzbuzz '(1 2 3 4 5 6 7 8 9 10))
More about special forms (in general): https://www.cs.utexas.edu/ftp/garbage/cs345/schintro-v14/schintro_17.html
'(1 2 3 4 5 6 7 8 9 10)
Might want to look up the iota procedure.
(import (srfi srfi-41))
(define fizzbuzz
(stream-map
(lambda (x y) (or x y))
(stream-constant #f #f "fizz" #f "buzz" "fizz" #f #f "fizz" "buzz" #f "fizz" #f #f "fizzbuzz" )
(stream-from 1)))
(stream-for-each (lambda (x) (format #t "~A\n" x)) (stream-take 100 fizzbuzz))
#f #f "fizz" #f "buzz" "fizz" #f #f "fizz" "buzz" #f "fizz" #f #f "fizzbuzz"
Instead of writing this out manually, compute it and apply it to stream-constant.
Is using or
like that conventional in Scheme? Once I tried that in Python and was told not to exploit unintentional features.
>>9
Like what? Instead of `(if x x y)`? Sure, that is common.
Once I tried that in Python and was told not to exploit unintentional features.
I don't do Python, but it doesn't seem to me like an "unintentional feature":
https://docs.python.org/3/reference/expressions.html#boolean-operations
Note that neither and nor or restrict the value and type they return to False and True, but rather return the last evaluated argument. This is sometimes useful, e.g., if s is a string that should be replaced by a default value if it is empty, the expression s or 'foo' yields the desired value.
>>10-11
Oh right, in my case I was using and
to guard a function with side effect. I guess in Scheme I would have just used when
or unless
.
>>8
And to compute it you need to write...
>>13
Something like this:
(define (fizzbuzz n)
(with-output-to-string
(lambda ()
(when (zero? (remainder n 5)) (display "fizz"))
(when (zero? (remainder n 3)) (display "buzz"))
(when (zero? (port-position (current-output-port))) (display n)))))
And to compute it you need to write...
Two stream-constants with k-1 #fs and one "meme", stream-map over them with an appropriate lambda and take the lcm into a list for apply.
>>15
Biting for another meme thread?
>>16
The difference between "another meme thread" and not hardcoding a precomputed '#f #f "fizz" #f "buzz" "fizz" #f #f "fizz" "buzz" #f "fizz" #f #f "fizzbuzz"' should become obvious upon a moment of reflection.
How to deal with people who put the closing paren on its own line?
>>18
Learn how to use a code formatter.
I get help from real people. http://www.datacamp.com
Calculating qualities. 300 000 page views regularly.
600 grand yearly.
how to even decide, the "content style", qualities.
i just need to know the right stuff to the right number. also maybe why
Help! Why is Scheme hopelessly broken? I cannot even get the answer to 1 + 1
Guile:
scheme@(guile-user)> 1 + 1
$1 = 1
$2 = #<procedure + (#:optional _ _ . _)>
$3 = 1
scheme@(guile-user)>
MIT Scheme:
1 ]=> 1 + 1
;Value: 1
1 ]=>
;Value: #[arity-dispatched-procedure 12]
1 ]=>
;Value: 1
1 ]=>
>>23
You forgot to switch to your blub syntax:
scheme@(guile-user)> ,L ecmascript
Happy hacking with ECMAScript! To switch back, type `,L scheme'.
ecmascript@(guile-user)> 1 + 1;
$1 = 2
>>24
What blub? Lisp is the ultimate blub language, but the clueless lispers are too blind, arrogant, and out of touch to realize it. I feel sorry for those Lisp programmers who suddenly realize that they have been using a blub language all along. The sanatoriums may not be able to help these poor people. As they say, ignorance is bliss.
>>24
Does that make Node.js obsolete?
I generally feel sorry for the oppressed Schemers and their poor programming language, but now I feel happy that they have a way to escape into the free land of JavaScript where they are able to taste freedom for the first time.
To switch back, type `,L scheme'.
Never!
Does that make Node.js obsolete?
No, Node.js is still required to easily get your files https://textboard.org/prog/422 overwritten by malware.
Furthermore: https://www.gnu.org/software/guile/manual/html_node/ECMAScript.html
ECMAScript was not the first non-Schemey language implemented by Guile, but it was the first implemented for Guile’s bytecode compiler. The goal was to support ECMAScript version 3.1, a relatively small language, but the implementor was completely irresponsible and got distracted by other things before finishing the standard library, and even some bits of the syntax. So, ECMAScript does deserve a mention in the manual, but it doesn’t deserve an endorsement until its implementation is completed, perhaps by some more responsible hacker.
In the meantime, the charitable user might investigate such invocations as ,L ecmascript and cat test-suite/tests/ecmascript.test.
Node.js is still required to easily get your files https://textboard.org/prog/422 overwritten by malware.
That's a great way to discourage the use of JavaScript. Lispers should launch more of such attacks on the JavaScript ecosystem, as retaliation for the publication of the heretical JSICP.
>>28
That will just seed hatred and hostility. It would be more productive to write more useful software in Lisp than there is written in JavaScript and show its simplicity and hackability to people.
>>29 there is no useful software written in javascript.
Lisp could only replace js if people decided to wrote harmful software in it.
how do i make C program that saves gif. super thank you
>>31
With `fwrite()`.
>>30
But then there will be no software written in JavaScript and a bunch of harmful software written in Lisp. It doesn't seem advantageous.
BTW there is useful software like OnlyOffice or Jitsi.
>>35 so any c compiler knows how to fwrite
>>35 so any c compiler knows how to fwrite
How do I find good programming books? Most that I come across end up being garbage.
>>37
I could reveal over thirty reading recommendations, if that would help.
man man
>>37
Avoid anything that says it will teach you something quickly ("learn foo in 24 days" or similar) and avoid books that are written for beginners.
I feel like most books are written for beginners, even those that claim not to be.
Is this guide fine? http://jaredkrinke.github.io/learn-scheme/index.html
I'm reading it.
is not there any other windows software written in mit-scheme besides edwin?
>>42
I recommend Teach Yourself Scheme in Fixnum Days.
https://ds26gte.github.io/tyscheme/
Other free Scheme programming books:
https://ebookfoundation.github.io/free-programming-books/books/free-programming-books-langs.html#scheme
Thank you.
>>45
But to reach an intermediate level in Scheme, it may be necessary to read SICP, Lisp in Small Pieces, and one of the Scheme specifications (e.g. R5RS or R7RS-small).
R5RS or R7RS-small
Are we stuck in a python2/3 situation?
>>46
No, Scheme has always been fractured due to incompatibilities between implementations.
There is currently an ideological split between big Scheme (R6RS) and small Scheme (R5RS/R7RS-small).
We no longer support OS/2, DOS, or Windows, though it's possible that this software could be used on Windows Subsystem for Linux (we haven't tried).
>>49
but that has nothing to do with the subject...
>>38
Please do.
>>51
Okay. They're on this website: http://verisimilitudes.net
Articles are arranged as YYYY-MM-DD or ISO 8601. Every date ending in fifteen since 2019 is a review. Not all reviews concern programming. Everything is also available over Gopher.
Follows are some of my favourite reviews:
http://verisimilitudes.net/2019-07-15
http://verisimilitudes.net/2019-08-15
http://verisimilitudes.net/2020-09-15
http://verisimilitudes.net/2020-10-15
http://verisimilitudes.net/2022-01-15
http://verisimilitudes.net/2022-06-15
Why madmen still use light themes these days? Your website is unreadable without browser plugins which fix your CSS colors.
Don't fall for the meme, dark themes are objectively worse for your eyes.
What meme? I feel how my eyes are aching from light background. It's not a meme, it's classic palette since TTY terminals are "dark themed". Light theme is invented by stupid GUI bloat advocates like Jobs and Gates.
Poweruser CLI-dweller hygiene requires dark theme.
>>53
I have no problem with reading light themes or dark themes. Works for me.
Why should I care about you? Should I maybe also care about Windows users and stop talking about GNU/Linux not to hurt their feelings?
It's a fact that many people strongly prefer dark theme even during daytime, otherwise there wouldn't exist so many browser plugins like DarkThemeCSS. A blogger must be an idiot to ignore such strong preference among potential readers.
It's a fact that dark themes are worse for your eyes than light themes. If you want to harm yourself, that's your choice. But you can't demand that other's eyes should be damaged too, just because you happen to be an idiot.
>>57
People who cannot adapt to a wide range of stimulus are inherently weak.
not using solarized dark or the objectively superior solarized light.
Proofs or fuck off.
Why women don't adapt to rapist's dick in their anus? Inherently weak, probably.
Can you posts studies supporting your statement. I want to know if using dark theme is necessary/
I never stated anything about "objective facts" like you did. My rant is about my own comfort enforced with the fact that many people prefer dark theme.
But if you are talking about "objectivity", feel free to provide links to medical research. Otherwise fuck off with your fake "objectivity".
Anyway, since you are a moron, I can come up with a nice link myself: https://ssb22.user.srcf.net/css/dark.html
All dark theme cons listed there are either situational or would never happen with proper web design i.e. large fonts.
>>63
Sorry that was my first post in the thread. This proves that er need names or randomized IDs to recognize posters.
enforced
I mean, empowered.
>>64
No, IDs are bad for discussion, also they are not ideal for detecting identity.
Sorry, my reply is not personally to you, but for morons above, who are talking about white background "objectively better for health" with no proofs.
ur a mron. heccin dummy!
:-*
day
light mode
night
dark mode
https://dl.acm.org/doi/fullHtml/10.1145/3357251.3357584
https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9363189
>>69
Too stereotypical. My room "home office" is dark during day. I don't work outdoors.
A blogger must be an idiot to ignore such strong preference among potential readers.
Just read it over Gopher then, using a terminal with the desired preferences, and stop with this nonsense.
I can read gopher or www version through Emacs or, let's say, lynx, or just click Ctrl+Shift+A in FF to add this light-themed toilet to DarkReader, but this doesn't do design of that blog any better.
Why is it always the dark theme moles that whine about light themes? Will your eyes fly out of the eye sockets and into your asshole if the colors are too bright?
My dick will fly into your asshole if you don't shut up and apologize for your behavior.
my anus will wrap around your dick unless you allow such behavior
>>75
Good luck with that. I don't even have my 455 TCP open.
>>74
because they are paupers lost in the darkness
they can not bear us, beacons of light
does anyone have the book "the schematics of computation" by vincent manis?
i have never seen it circulating on the interwebz... by the way, his scheme implementation for windows (winscm) is even more rare
not mit-scheme but give it a try :3
or even better, jaffer's scm
I am trying to solve SICP Exercise 1.16. Here is my solution:
(define (fast-expt-iter b n)
(cond ((= n 1) b)
((even? n) (fast-expt-iter (square b) (/ n 2)))
(else (fast-expt-iter (square b) (- n 1)))))
I can't find any error when I work it out on paper myself; but when I run it I get the wrong answer.
What am I missing here?
keep, along with the exponent n and the base b, an additional state variable a, >and define the state transformation in such a way that the product ab^n is >unchanged from state to state.
Aren't you missing the 'a' variable?
>>82
You change b== the same way in both cases but change ==n
differently, does that make sense?
>>82
Let X{t} be the value of the local variable X after t steps. Let X be the unmodified value passed to you from the outside. Initial conditions:
a{0} = 1, b{0} = b, n{0} = n
Invariant:
a{0} * b{0}^n{0} = b^n
Recall that when deconstructing a number into bits with parity or modulo 2 and right shift or quotient 2, you proceed from the LSB to the MSB. Keeping that in mind, the algorithm can be recovered from the invariant by the usual process of assuming you've already performed k steps correctly and you just need to perform step k+1. In other words you just need a state transformation:
(a{k}, b{k}, n{k}) --> (a{k+1}, b{k+1}, n{k+1})
The invariant assures you that:
a{k} * b{k}^n{k} = b^n
Therefore if n{k} = 0 then a{k} = b^n and you're done. Otherwise you're in this situation:
n{k}
+-------------------+
| |
+---------------+ +-----------+
|bit bit bit bit|bit|bit bit bit| = n
+---------------+ ^ +-----------+
n{k+1} | k bits
current
The bit deconstruction equations can be read off the diagram:
n{k+1} = n{k} // 2 [eq1]
current = n{k} mod 2 = 0 or 1
2 * n{k+1} + current = n{k}
2 * (n{k} // 2) + (n{k} mod 2) = n{k}
where // stands for integer division. The next invariant that you must satisfy:
a{k} * b{k}^n{k} = b^n = a{k+1} * b{k+1}^n{k+1}
Use [eq1]:
a{k} * b{k}^n{k} = a{k+1} * b{k+1}^(n{k} // 2)
You need to account for the halving of the exponent to maintain the invariant. You can do so in either a{k+1} or b{k+1}. But a{k+1} has no exponent applied to it, so it would need to compensate with its own internal exponentiation using some dependence on n{k}. This would make the process recursive, but the exercise https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-11.html#%_thm_1.16 requires the process to be iterative. So you account for the halving of the exponent in b{k+1}. To account in a base for the halving of its exponent you square the base, as the exercise already suggests.
b{k+1} = b{k}^2 [eq2]
Plug it back into the invariant:
a{k} * b{k}^n{k} = a{k+1} * (b{k}^2)^(n{k} // 2)
To compute nested powers multiply the exponents.
a{k} * b{k}^n{k} = a{k+1} * b{k}^(2 * (n{k} // 2))
Use the [eq1] group to rewrite the exponent:
a{k} * b{k}^n{k} = a{k+1} * b{k}^(n{k} - (n{k} mod 2))
Simplify to get a{k+1}:
a{k+1} = a{k} * b{k}^(n{k} mod 2)
You don't need to actually exponentiate here because (n{k} mod 2) can only be 0 or 1.
a{k+1} = | a{k} if (n{k} mod 2) = 0
| a{k} * b{k} if (n{k} mod 2) = 1
[eq3]
a{k+1} = | a{k} if current bit = 0
| a{k} * b{k} if current bit = 1
Together [eq1], [eq2] and [eq3] specify the state transformation. This sort of technique can be used in general to recover algorithms from invariants.
>>83-85
Thank you for your help. I believe I have found a solution:
(define (fast-expt-iter b n a)
(cond ((= n 0) a)
((even? n) (fast-expt-iter (square b) (/ n 2) a))
(else (fast-expt-iter b (- n 1) (* a b)))))
Observing if n is even:
```b^n = (b^2)^n/2```
and do:
```(b, n, a) -> (b^2, n/2, a)```
Observing if it is not:
```b^n = b*b^n-1```
and do:
```(b, n, a) -> (b, n-1, a*b)```
Where it is seen:
(fast-expt-iter 2 6 1)
-> (fast-expt-iter 4 3 1)
-> (fast-expt-iter 4 2 4)
-> (fast-expt-iter 16 1 4)
-> (fast-expt-iter 16 0 64)
-> 64
I was a bit lost when >>85-san went on about deconstructing the bits, but I will thank the good explanation of the state transformation for helping me work this out.
Orders of growth and the nature of these iterative processes are still a bit arcane to me, but I feel as though the fog has lifted. Thank you!
Does anyone actually way Lisp the canonical way, top-down, first writing the highest-level parts and then filling in the details?
>>87
Why is top-down considered the canonical way?
Imagine in the future: one or two highly paid programmers using their creativity to write the highest-level parts, leaving many minimum wage programmers with the menial task of filling in the blanks. This is similar to all the "fill in the blanks" homework for schoolchildren. Great for reducing costs.
Are small-step semantics somehow connected to continuation-passing style? It reminds me of that.
>>89
https://rolph-recto.github.io/posts/2016-12-26-implementing-callcc.html
https://srfi.schemers.org/srfi-236/srfi-236.html
Why is this implemented as a macro? Wouldn't this work:
(define (perform . l) (begin))
I wish you could comment bash like this:
find . -type f -print0 \ # list all files
| xargs -0 -n1 ffprobe 2>&1 \ # extract media information
| awk '...' \ # do something with it
| less
>>92
You don't need to break lines on pipes.
find . -type f -print0 | # list all files
xargs -0 -n1 ffprobe 2>&1 | # extract media information
awk '...' | # do something with it
less
Should work just fine.
>>93
But it does not look as cool as the other.
>>94
What do you mean? It looks way cleaner to me.
>>91
Probably, but then you don't get special form evaluation semantics which are likely intended.
How do i stop getting stuck in autistic pits with designing software while not giving up and making something horrible?
>>97
Stop using OOP.
>>98
I use functional
Luk mom dubs
>>97
Make something horrible first. If you understand why your code is so horrible, then I'd expect that you should be able to refactor the code so it sucks less.
>>101
I have no will to afterwards and will most likely trash it then repeat the cycle