manlen p1p2=abs(fst p1-fst p2)+abs(snd p1-snd p2)
points n = [(x,y)|x<-[-n..n], y<-[-n..n]]]
circle n = [p | p <-points n, manlen(0,0)p == n ]
I am not sure manlen(0,0)p==n
in the last list inclusion notation.
Why do we take p==n for the manlen argument?
In haskel, infix operators that take arguments on both sides, such as ==
, have lower priority than normal function calls.Therefore, manlen(0,0)p==n
is interpreted as (manlen(0,0)p)==n
instead of manlen(0,0)(p==n)
.This will return the Bool, so it will be a filter.Hence
mancircle n=[p|p<-points n, manlen(0,0)p==n]
returns only the manlen(0,0)p
element where manlen(0,0)p
is n.
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
914 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.