From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/107170 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: supp-ran.lua makes code unable to work in ConTeXt Date: Fri, 1 May 2020 17:38:31 -0400 (EDT) Message-ID: References: <6c7d66fc-848b-4c24-b78d-13932d052c41@xs4all.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1113681752-1588369112=:196463" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="119049"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Alpine 2.22 (LNX 394 2020-01-19) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri May 01 23:38:55 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jUdN1-000Usm-Hg for gctc-ntg-context-518@m.gmane-mx.org; Fri, 01 May 2020 23:38:55 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A3595D81; Fri, 1 May 2020 23:38:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KXB_UJ2PSdj3; Fri, 1 May 2020 23:38:36 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B0EB1190240; Fri, 1 May 2020 23:38:36 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B6BF6DAE for ; Fri, 1 May 2020 23:38:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cX0GO3DMYscO for ; Fri, 1 May 2020 23:38:34 +0200 (CEST) Received-SPF: Softfail (mailfrom) identity=mailfrom; client-ip=132.206.73.2; helo=orford.cim.mcgill.ca; envelope-from=adityam@umich.edu; receiver= Original-Received: from orford.cim.mcgill.ca (smtp.cim.mcgill.ca [132.206.73.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 961F0D81 for ; Fri, 1 May 2020 23:38:34 +0200 (CEST) Original-Received: from adi-thinkpad.local (198-84-255-218.cpe.teksavvy.com [198.84.255.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adityam) by orford.cim.mcgill.ca (Postfix) with ESMTPSA id AD753FA6BC for ; Fri, 1 May 2020 17:38:32 -0400 (EDT) In-Reply-To: <6c7d66fc-848b-4c24-b78d-13932d052c41@xs4all.nl> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:107170 Archived-At: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1113681752-1588369112=:196463 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 1 May 2020, Hans Hagen wrote: > On 5/1/2020 6:12 AM, Jairo A. del Rio wrote: >> I've adapted the following code to make mazes in LuaLaTeX and ConTeXt:= =20 >> https://www.rosettacode.org/wiki/Maze_generation#Lua >>=20 >> I defined a modified version to make content visible to TeX and I saved = in=20 >> a file named maze.lua: >>=20 >> function make_maze_tex(w, h, m) >> =C2=A0 w =3D w or 16 >> =C2=A0 h =3D h or 8 >> >> =C2=A0 local map =3D initialize_grid(w*2+1, h*2+1) >> >> =C2=A0 function walk(x, y) >> =C2=A0 =C2=A0 map[y][x] =3D false >> >> =C2=A0 =C2=A0 local d =3D { 1, 2, 3, 4 } >> =C2=A0 =C2=A0 shuffle(d) >> =C2=A0 =C2=A0 for i, dirnum in ipairs(d) do >> =C2=A0 =C2=A0 =C2=A0 local xx =3D x + dirs[dirnum].x >> =C2=A0 =C2=A0 =C2=A0 local yy =3D y + dirs[dirnum].y >> =C2=A0 =C2=A0 =C2=A0 if map[yy] and map[yy][xx] then >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 map[avg(y, yy)][avg(x, xx)] =3D false >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 walk(xx, yy) >> =C2=A0 =C2=A0 =C2=A0 end >> =C2=A0 =C2=A0 end >> =C2=A0 end >> >> =C2=A0 walk(math.random(1, w)*2, math.random(1, h)*2) >>=20 >> ...ext/tex/texmf-context/tex/context/base/mkiv/supp-ran.lua:30: C stack= =20 >> overflow=20 >> Why does it happen? I guess it has something to do with math.randomseed,= =20 >> but I don't know how to avoid this error message. > no, it's just lua running out of stack space so it depends on the binary= =20 > (and als the initial random value) But why is it running out of stack? Isn't the walk function tail recursive,= in which case it should not cause a stack overflow (https://www.lua.org/pi= l/6.3.html). Aditya --8323329-1113681752-1588369112=:196463 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --8323329-1113681752-1588369112=:196463--