
@alexharsanyi Nice blog post on Ishido. I am wondering whether the part, where you make sure the first six tiles have unique colors and images could be done easier. Instead of “moving” things, I’d shuffle until I get a usuable order:
(define shuffled (let loop ([candidate (shuffle all)]) (if (six-unique candidate) candidate (loop)))

I am thinking the proportion of shuffles where the first 6 tiles are unique are so large, that the number of retries will be low.

I’m not sure I like algorithms that are not guaranteed to terminate. Also, I’m not sure how you define “easier” — you would have to show how six-unique
is implemented, so you might not save on the lines of code and the complexity of the explanation.

I am not worried about the random nature of “randomize, test and repeat if necessary”. (I have used that trick multiple times). Yes, it is only the “moving” part that disappears. My thinking is that six-unique
will be simpler without the “moving” part.

Is it a popular game?

I didn’t know about it.

at work I have to deal with a lot of things that “statistically should never happen”, so I have a strong dislike for such things :slightly_smiling_face:

also, the game is one of the very few that I ever played ( I am not a game person )



@jcoo092

I am working on a math web-site with lot of random exercises. Here is how I find a random circle with center (a,b) and radius r where the center is close to (0,0) and the circle itself doesn’t extend too far:
(defr [(a b) (random-small 5)]
[(r) (random-small 5)]
#:where (and (> r 0)
(<= (+ (* a a) (* b b)) 16)
(<= (+ r (+ (* a a) (* b b))) 7)))
Here the clauses of defr
will find random a, b and r. Then the where-predicate is checked. If the predicate fails, defr
will loop and find new values for a, b and r.

So far the generate-and-test approach has worked pretty well.

From the reference it sounds like fixnums should be 62 bits + 1 bit for the sign and that appears to be the case on BC, but not on CS:
Welcome to Racket v7.7.0.10 [cs].
> (fixnum? (sub1 (expt 2 62)))
#f
> (fixnum? (sub1 (expt 2 61)))
#f
> (fixnum? (sub1 (expt 2 60)))
#t
Is this expected?

I believe fixnums are one bit smaller on CS.

Chez Scheme has most-positive-fixnum
if you need to check.

Looks like it:
> ((vm-primitive 'most-positive-fixnum))
1152921504606846975
> (sub1 (expt 2 60))
1152921504606846975
Thanks

Is this because chez uses the extra bits to tag more primitive values than Racket BC does?

I think so - I don’t know which tag scheme CS uses.

Yes, it’s due to more bits for tags.


Three bits are used for tags, fixnums effectively get two patterns (000 and 100) on 32-bit machines, so that’s why there’s 1 bit less room for fixnums on a 32-bit machine, but 2 bits less on a 64-bit machine.

It looks like I fixed the guide but not the reference, so I’ll fix the reference now.

Makes sense. Thanks for the link!

Yep, those

I am trying to build racket from source on mac. I get this error: a - src/validate.o
a - src/vector.o
a - ../foreign/foreign.o
ranlib libracket.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: libracket.a(unwind.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/make racketcgc
mkdir -p Racket.framework/Versions/5.1.1.7
gcc -o Racket.framework/Versions/5.1.1.7/Racket -pthread -framework CoreFoundation -dynamiclib -all_load libracket.a libmzgc.a -ldl -lm -liconv -lffi
rm -f Racket.framework/Racket
ln -s Versions/5.1.1.7/Racket Racket.framework/Racket
gcc -I. -I../../racket/include -g -O2 -Wall -DOS_X -D_DARWIN_UNLIMITED_SELECT -pthread -fno-common -DINITIAL_COLLECTS_DIRECTORY='"'"`cd ../../racket/../../collects; pwd`"'"' -c ../../racket/main.c -o main.o
gcc -o racketcgc -pthread main.o -Wl,-headerpad_max_install_names -F. -framework Racket -ldl -lm -liconv -lffi
/usr/bin/install_name_tool -change "Racket.framework/Versions/5.1.1.7/Racket" "@executable_path/Racket.framework/Versions/5.1.1.7/Racket" "racketcgc"
cd gc2; /Library/Developer/CommandLineTools/usr/bin/make all
mkdir xsrc
/Library/Developer/CommandLineTools/usr/bin/make xsrc/precomp.h
env XFORM_PRECOMP=yes ../racketcgc -cqu ../../../racket/gc2/xform.rkt --setup . --cpp "gcc -E -I./.. -I../../../racket/gc2/../include -DOS_X -D_DARWIN_UNLIMITED_SELECT -pthread -fno-common " --keep-lines -o xsrc/precomp.h ../../../racket/gc2/precomp.c
Copying tree...
make[4]: *** [xsrc/precomp.h] Abort trap: 6
make[3]: *** [all] Error 2
make[2]: *** [3m] Error 2
make[1]: *** [3m] Error 2
make: *** [all] Error 2
Any ideas?

When non-termination is a concern I guess there is call-with-limits
and friends. https://docs.racket-lang.org/reference/Sandboxed_Evaluation.html#(def._((lib._racket%2Fsandbox..rkt)._call-with-limits))

That might already be covering @soegaard2 in the context of a web server? I vaguely recall something to do with terminating HTTP responses that take “too long”.

Anyway I can appreciate @alexharsanyi not wanting to see more of the bane of his professional existence. :slightly_smiling_face:

Good advice. I chose to generate the exercises off-line as a bunch of data files - and then let he web-server pick randomly from the available exercises.

I think racketcgc
must be hitting an abort()
call, but since it doesn’t print anything before, we’ll need a stack trace to figure out this one.

Go to racket/src/build/racket/gc2

Run env XFORMPRECOMP=yes lldb ../racketcgc

Then run -cqu ../../../racket/gc2/xform.rkt --setup . --cpp "gcc -E -I./.. -I../../../racket/gc2/../include -DOS_X -D_DARWIN_UNLIMITED_SELECT -pthread -fno-common " --keep-lines -o xsrc/precomp.h ../../../racket/gc2/precomp.c

I expect that lldb will break at an abort signal, and then bt
will give us some hints

Good news and bad news. I have gotten past the problematic point, but I changed two things at once. I fetched the pmatos new commits and used make in-place
instead of just make
.

I am a bit confused. The build is done. It looked as everything went fine. Packages were downloaded and built. Docs were rendered. But the bin
directory is empty and build
only contains config
. Am I looking the wrong place?

The build command was simple make in-place
.

The more interesting build
is racket/src/build
. But it’s puzzling if racket/bin
is empty.

soegaard@mbp2 GitHub % cd racket/src/build
soegaard@mbp2 build % ls
Makefile config.log config.status foreign gracket plot racket

soegaard@mbp2 GitHub % ls racket/build
config
soegaard@mbp2 GitHub % ls racket/bin

Does make in-place
depend in any way of the racket
that happens to be in the terminal path? (it happens to be a racket 7.5).

Found it!

Don’t know why, but the result inded in racket/racket/bin and not racket/bin

Okay - I think what broke the build in the first place. I did a: git fetch upstream pull/30/head:pr30 thinking it would fetch PR 30 from racket/math, but it of course fetched PR 30 from racket/racket.

A git / Github question. I have a cloned and build racket/racket from Github. Now I want to test PR30 from racket/math. I have added a remote upstream-math
pointing to racket/math
. And now I attempt to fetch PR30 using git fetch upstream-math pull/30/head:pr30
following https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally
However, I get the following error:
soegaard@mbp2 racket % git remote -v
origin git@github.com:soegaard/racket.git (fetch)
origin git@github.com:soegaard/racket.git (push)
upstream <https://github.com/racket/racket> (fetch)
upstream <https://github.com/racket/racket> (push)
upstream-math <https://github.com/racket/math> (fetch)
upstream-math <https://github.com/racket/math> (push)
soegaard@mbp2 racket % git fetch upstream-math pull/30/head:pr30
fatal: Refusing to fetch into current branch refs/heads/pr30 of non-bare repository

It may be due to racket/racket and racket/math being to separate repos. But if I clone racket/math locally, how to do I get the local clone of racket/racket use my clone of racket/math?

In the root directory of your racket
checkout, use racket/bin/raco pkg update —clone extra-pkgs/math
. Then work in extra-pkgs/math
.

Thanks!

Should be raco pkg update
above

racket/bin/raco pkg update --clone extra-pkgs <https://github.com/racket/math>

Seems to work, but I get this in the end: ...
raco pkg update: package conflicts with existing installed item
package: <https://github.com/racket/math>
item category: doc
item name: "math"
Do I need to link math
to the folder extra-pkgs/math
?

Found the cause: somehow, links.rktd
contains both (root "pkgs/drracket")
and (root "../../../racket-repos/drracket/drracket")
(along with similar packages). Deleting the former fixes the problem.

That looks like you may have two math
s installed somehow. When you use raco pkg update --clone
, it makes the clone the installed package.

Do you have anything in ~/Library/Racket/development
?

soegaard@mbp2 development % cd ~/Library/Racket/development
soegaard@mbp2 development % cat links.rktd
(("math" "../../../Dropbox/GitHub/racket/extra-pkgs/math"))
soegaard@mbp2 development % cat share/info-cache.rktd
(((rel up up up up #"Dropbox" #"GitHub" #"racket" #"extra-pkgs" #"math") (collection deps implies pkg-desc pkg-authors) (lib "math") 1 0))

That looks ok.

I don’t think you want that “links.rktd”.

Do you once use raco link
with a Git checkout of racket
? If so, raco pkg
generally doesn’t see non-package links, so that would explain what went wrong.

Yes, before the raco pkg update
tip, I make a git clone
copy of racket/math
and then used raco link
. Then I removed the link, and used raco pkg update
instead.

Should I just remove links.rktd ?

Yes. And never use raco link
again. :slightly_smiling_face:

ok!

I decided to start from scratch. Cloned soegaard/racket. Did a make in-place
. Then racket/bin/raco pkg update --clone extra-pkgs <https://github.com/racket/math>
After that: cd extra-pkgs,
git remote add upstream-math <https://github.com/racket/math>
git fetch upstream-math pull/30/head:pr30
git checkout pr30
Then cd ..
racket/bin/raco setup
But it seems that the changes from pr30 isn’t picked up. (I am testing with (require math) (gamma 1+i)
.
The
raco pkg show -l mathcommand still refers to the checksum before pr30 is applied:
soegaard@mbp2 racket % racket/bin/raco pkg show -l mathInstallation-wide:
Package[*=auto] Checksum Source
math* ad61293060bc718f3628e17a673658337fb7f187 (catalog “math” "<git://github.com/racket/math/?path=math>")User-specific for installation “development”:
`

The output of racket/bin/raco pkg update -h
says:
`--clone <dir> : Clone Git and GitHub package sources to <dir> and link`
And it did clone both math-lib
and friends:
soegaard@mbp2 racket % cd extra-pkgs
soegaard@mbp2 extra-pkgs % ls
math math-doc math-lib math-test

And checking with less math-lib/math/special-functions.rkt
I can see that pr30 has been fetched.

Hmmm. soegaard@mbp2 racket % racket/bin/raco link -l \| grep math
root path: "/Users/soegaard/Dropbox/GitHub/racket/racket/share/pkgs/math"
root path: "/Users/soegaard/Dropbox/GitHub/racket/racket/share/pkgs/math-test"
root path: "/Users/soegaard/Dropbox/GitHub/racket/racket/share/pkgs/math-lib"
root path: "/Users/soegaard/Dropbox/GitHub/racket/racket/share/pkgs/math-doc"
root path: "/Users/soegaard/Dropbox/GitHub/racket/racket/share/pkgs/math-x86_64-macosx"

So it keeps using the math lib under /racket/share/
.

In my clone I don’t have the math packages under racket/share after I clone them.

Will setup -c
clean up that problem?

First, that’s odd. Second, as @maueroats says, usually you create a subdirectory of extra-pkgs
for things. Third, I strongly recommend using one of the GitHub command line tools (either hub
or gh
) for merging pull requests easily.

Aha, though I had been doing it wrong so I deletd my comment. :slightly_smiling_face:

So not `racket/bin/raco pkg update --clone extra-pkgs <https://github.com/racket/math>
but instead: racket/bin/raco pkg update --clone extra-pkgs/math <https://github.com/racket/math>
?

I just do raco pkg update --clone math
and I think it uses the package repo to figure out where to get it from.

In time, I probably want it to fetch from soegaard/math instead of racket/math on Github.

I am trying raco setup -c
now.

Sounds like the problem is that it is cloning but does not recognize what package should be removed from pkgs/share? My pkgs/share have none of the packages I cloned, but I think I also did the clone before the first build… maybe…

@soegaard2 usually I do cd extra-pkgs; raco pkg update --clone math

ah, probably the issue is that racket/math
does not refer to any of the packages you want

they are all subdirectories of that repo

^^ Nailed it. Watch for the step where raco trashes the old packages before going through everything. (This one makes a folder at the top level, oops.) raco pkg update --clone sgl <https://github.com/racket/sgl>
Querying Git references for sgl at <https://github.com/racket/sgl>
Updating:
sgl
Querying Git references for sgl at <https://github.com/racket/sgl>
Cloning remote repository <https://github.com/racket/sgl>
to /home/.../racket/sgl
git clone -b master <https://github.com/racket/sgl> .
Fetching from remote repository <https://github.com/racket/sgl>
git fetch <https://github.com/racket/sgl> master
Cloning repository locally for staging
git clone --shared /home/.../racket/sgl /var/tmp/15938065091593806509794-sgl
git checkout 7999abdf79058cc709da0e49dee4ec0569249085
Merging commits at /home/docmo/Documents/2020b/racket/sgl
git merge --ff-only 7999abdf79058cc709da0e49dee4ec0569249085
Already up to date.
Uninstalling to prepare re-install of sgl
Moving sgl to trash: /home/.../racket/racket/share/pkgs/.trash/1593806511-0-sgl
Re-installing sgl

There’s a bit in this video where Andy talks about the tagging in Chez https://youtu.be/BcC3KScZ-yA\|https://youtu.be/BcC3KScZ-yA

I didn't the "Uninstalling" part. I got:
soegaard@mbp2 racket % racket/bin/raco pkg update --clone extra-pkgs <https://github.com/racket/math>
Querying Git references for math at <https://github.com/racket/math>
Updating:
math
Querying Git references for math at <https://github.com/racket/math>
Cloning remote repository <https://github.com/racket/math>
to /Users/soegaard/Dropbox/GitHub/racket/extra-pkgs
git clone -b master <https://github.com/racket/math> .
Fetching from remote repository <https://github.com/racket/math>
git fetch <https://github.com/racket/math> master
Cloning repository locally for staging
git clone --shared /Users/soegaard/Dropbox/GitHub/racket/extra-pkgs /var/folders/01/7wc7rqn95cl_2w6wvjt2_x440000gn/T/15938054081593805408714-math
git checkout ad61293060bc718f3628e17a673658337fb7f187
raco pkg update: package conflicts with existing installed item
package: <https://github.com/racket/math>
item category: doc
item name: "math"

Wait - racket/math
and math
are different.

I am working on math
.

http://github.com/racket/math\|github.com/racket/math contains a bunch of subdirectories, one of which is called math
and corresponds to the math
package. Others are called things like math-lib
and math-doc
and correspond to those packages.

Oooh.

I think what you did was replace the “math” package (which is empty and just depends on other things) with a package that contains a collection named “math” that has subcollections named “math-lib” etc

which is not what you want.

You might try the following: raco pkg remove --force --no-setup math
rm -rf extra-pkgs
mkdir extra-pkgs
cd extra-pkgs
raco pkg install --clone math

I get: soegaard@mbp2 extra-pkgs % ../racket/bin/raco pkg install --clone math
Inferred package name from given
—clone’ path
package: math
given path: mathResolving “math” via https://pkgs.racket-lang.org
packages from a Git repository would not share a local clone
repository: <git://github.com/racket/math/>
local clone: /Users/soegaard/Dropbox/GitHub/racket/extra-pkgs/math/
packages for local clone:
math
non-clone packages:
math-doc
math-test
math-libConvert the non-clone packages to clones, too? [Y/n/a/c/?]`

I suppose Y is the right choice?

Definitely

Imo better to have a bunch of extras than go through the pain of fixing it later… like I end up wanting to edit the docs, which would never happen if that repo was not just sitting there.

Still recompiling. :slightly_smiling_face:

What Sam means is that <https://github.com/racket/math>
is not the package source for the math
package. The simplest thing is to use just math
.

Okay - that explains (part of at least) my confusion.

Success! ./racket/bin/raco pkg install --clone math
worked.

I better write this down…

You could also use <https://github.com/racket/math?path=math>
, but the intent of raco pkg update --clone
is that you don’t have to go find the original package path. Let raco pkg update
can infer a clone source from the current math
installation.

Suppose I clone racket/math
on github to soegaard/math
also on github. Then I would need to use `<https://github.com/soegaard/math?path=math>
?

You could do that, but I generally find it easier to leave the clone attached (on the sense of the Git origin) to the repo that is registered with the package server. That way, any updates to the main repo get pulled by raco pkg update
. To pull and push at a different repo, I specify it explicitly in Git commands, such as git pull git@github.com:mflatt/math bug-fix-for-pr
or git push git@github.com:mflatt/math master:bug-fix-for-pr
.

Best to write it down in docs

I also have things configured so that I can push to git@github.com:racket/math
but not <https://github.com>:racket/math
, where the https
form is what raco pkg update --clone
sets at the origin. That way, it’s much more difficult for me to accidentally push to the main branch. But I guess that trick won’t work for anyone who has https
authentication set up properly.

What I did is git remote add patch git@github.com:sorawee/typed-racket.git

Thanks for the advice. I like pushing to the soegaard/x first before making a pull request to racket/x. The github diffs helps catching silly mistakes.
Thanks also to @samth and @maueroats .
I see that raco pkg update
pulling any updates is a good thing. But doesn’t that imply ( if origin
points to racket/math
) that a git push
will push directly to the racket repo. (something I’d like not to do by mistake).

Then you can git push patch branchname

@soegaard2 you can git push -u patch branchname

This will set default push to patch

rather than origin

That matches git remote add upstream-math <https://github.com/racket/math>
Just with patch
instead of upstream-math
?

When you raco pkg update --clone

racket/math
is already your origin
, I believe

So you should git remote add
to your local repo

Just checked. And yes --clone
makes racket/math
the origin.

@nata.chaykivska has joined the channel

Usually the remote set up by raco pkg update —clone is not pushable

Now that I’m finally back at my computer, my usual steps are: 1. Update to use a clone: cd extra-pkgs; raco pkg update --clone math
(and answer yes to the prompts) 2. Do some work, commit changes. 3. Set up a remote for my fork: hub fork
(the hub
tool is really great) 4. git push samth
(pushes to my fork) 5. hub pull-request
(creates a pull request using the current branch I’m on) Alternatively, if I want to be able to push directly to racket/math
, I would do hub remote add -p racket/math
, which creates a remote called racket
that I can push to, and keeps origin
the same and thus I can’t just accidentally do a git push
to the upstream repo.

Thanks @spdegabrielle :slightly_smiling_face:

@xiaobaoispig has joined the channel