logs archiveIRC Archive / Freenode / #emacs / 2010 / January / 27 / 1
Ober2
unf I hate it when a java IDE eats both cpus after changing a piece of code blocking all input updates until it's done
swathanthran
argh, listp is just checking for a cons cell. there isn't a predictae for "proper" list?
s/predictae/predicate/
jlf
swathanthran: from the backlog: (defun proper-list-p (L) (and (listp L) (null (cdr (last L)))))
courtesy of snogglethorpe
my entry was (defun proper-list-p (list) (or (null list) (and (listp list) (proper-list-p (cdr list)))))
swathanthran
ah, i was just about to read whether last would be a big thing not to use at this point.
jlf
i find the recursive solution more elegant myself
swathanthran
oh yeah, i was thinking of some c magic on last.. but seems like there isn't much..
(Action) takes jlf's
hober
why not just (defalias proper-list-p (l) (not (cdr (last l))))
jlf
l may not be a cons cell for one
hober
fine. (and (consp l) ..)
... which is just what you has posted before. :)
what was that about a backlog? :)
         

jlf
:)
rgr
ok, elisp gurus, could you take a look at this and tell me if there is a more succinct way to do it. the main function takes a single tag or a list of tags and returns true if the org-item tagslist contains either the tag or an element of the tags list. http://rgr.pastebin.com/d5932286b
it at least works. In particular I wonder if throw was the best option to quite the loop on first match.
s/quite/quit
damd
rgr: use `when'
no, sorry
the indentation confused me
rgr
and me ;)
damd
no, actually, the inner-most `if' could be `when'
rgr
any real advantage?
damd
no, just more idiomatic and emacs doesn't indent the then-clause as much
rgr
ok, I'll do that now ...
damd
i don't really see why you catch/throw stuff
rgr
to escape at first match
no point checking the rest
damd
there are better ways to do that
rgr
yes ..
I'm learning elisp - please tell me the better ways.
damd
you could use e.g. `find'
rgr
where?
jlf
the outermost if could be a when too, could it not?
rgr
I dont see how find would help.
jlf: probably
damd
jlf: i suppose it could, but it's not really clear
rgr
I'll change them in a tick and resubmit.
damd
i wish there was just an `any' in elisp...
rgr
to me the function is easy enough to understand based ony my c/whatever bg. I want to make it more lispy though.
damd: but back to find. How would that make it easier? I still want to exit when any element in the parameter list matches a tag for the org item being checked. hence I used the throw to escape.
         

damd
rgr: never mind 'find' on second thought, you can use recursion
rgr
I dont like recursion.
damd
why not?
that's lisp
rgr
but I would love to see how.
technomancy
(Action) doesn't like the fact that rgr doesn't like recursion
rgr
I find recursion used unnecssarily hard to follow. But thats my noobness in elisp.
technomancy
come on guys.
I left that wide open.
damd
time to get used to it :)
jlf
rgr: recursion makes things _easier_ to follow when used properly
damd
rgr: this is a good exercise for me too, i'm intrigued by it
,any
fsbot
damd: [->] anyone -- Please do not ask if anyone uses, knows, is good with, can help you
damd
... is there any `any' construct in emacs?
(defun any (predicate list) ...)?
technomancy
who's going to bring up not liking the fact that I don't like the fact that rgr doesn't like recursion? anybody?
rgr
jlf: I know what recursion is. I know and have used it. Used unneceesarily or too clevrely I find it doesnt help an awful lot. Shrug. But would lost to see how here.
damd
,loop
fsbot
42 ..(integer)
damd
ffs
,dolist
fsbot
hmm, ToDoList is at http://www.emacswiki.org/cgi-bin/community/ToDoList
jlf
rgr: i think we're in violent agreement
rgr
technomancy: I dont like the fact that they didnt take your bait either. Where's ams and telling me to read the manual?
jlf
<jlf> /ignore rgr [15:06]
rgr
lol
technomancy
hehe
rgr
Now tell me you'll help if I pay you.
jlf
one ams is enough
rgr
all of those Ifs could become whens. Doesnt really add much though.
damd
i got only this far: http://rgr.pastebin.com/m4b8639d1
now how do i do the recursion?
rgr
other than the nlistp check of course.
damd: you're the recursion king ;)
damd
rgr: i usually recurse in haskell ;P
any (`elem` x) xs
no explicit recursion required
rgr
heh. But come on, all you did was snip 4 lines ;)
yes ....
damd
yeah, but the answer is still the same, you should recurse ;P
rgr
I dont think I should. There is no advantage in recursion there at all.
jlf
hey guys i think i've solved the halting problem
details to follow
rgr
its a simple loop until match.
damd
rgr: recursion is like looping
s/like//
rgr
damd: I know what recursionis ....
damd
then why do we disagree?
rgr
because looping is not recursion.
damd
recursion is one way to loop
rgr
and this is simple enough ina one line loop.
looping is not recursion in any shape or form.
damd
and you said you want to know the lispy way to do it... the lispy way is through recursion
rgr
I dont think it is in thise case - I mean why? The dolist loop is so simple.
damd
well sure, if you like the throw/catch
you could use a simple `while' too
it's probably the fastest too
i'm just saying it's not lispy :/
rgr
I dont really. I really wanted a "break" but yeah while with "and" will do it too!
I'll try that too now ....
while is no good here.
it doesnt dolist ...
dolist and throw seems clear enough and efficient.
jlf
,(loop for x in '(1 2 3) do (if (evenp x) (return x)))
fsbot
oops, error. Symbol's value as variable is void: fs-for
damd
"break" constructs is not lispy, that's all i'm saying
ams
hm.
damd: then you don't know lisp.
damd
and `loop' is a cl-ism i think, so that's not *e*lispy
jlf
rgr: if you require cl you could use that
ams
rgr: what do you want to do?
rgr
ah, a return statement, didnt know about that.
jlf
it's "common elisp"!
ams
00:18 <rgr> looping is not recursion in any shape or form.
and sorry, but that is just bullsh*t.
rgr
ams I did it but wnated style guidelines. hang on. I'll repaste.
ams: not it isnt. Not in the context.
but lets not fight.... its all vocab ...
damd
rgr: if recursion isn't a way to loop then looping is not necessary to do programming, since e.g. haskell doesn't have while/dolist/for
rgr
I dont want to get into a silly semantics game. Its quite clear whats meant by looping here using dolist and recursion.
damd
i'm still interested to see what people come up with for this problem
rgr
ams : ok, elisp gurus, could you take a look at this and tell me if there is a more succinct way to do it. the main function takes a single tag or a list of tags and returns true if the org-item tagslist contains either the tag or an element of the tags list. http://rgr.pastebin.com/d5d0e8a7
damd
without cl
ams
what is a tag?
rgr
your mild rebukes and
corrections welcome.
see the test call
just a string.
damd
ams: he basically wants to do `member' with a special case
rgr
no not a special case at all.
damd: I grapple with haskell occasionally but its a real bi**h if you do not dedicate yourself to it, Use xmonad.
damd
rgr: it's troublesome at times, but i love the concept
ams
special case?
damd
ams: don't listen to me, apparently i've misunderstood the problem
ams
you just want to find if omething exits in the list tags?
hm.
rgr
I dont really know how better to describe it. It matches a single tag passed in or one of the tag list passed int.
ams
rgr: okie, thi is all confuing.
rgr
see the test function call.
ams
what the heck ins the input?
rgr
Oh leave it. it works.
ams
(if (nlistp tags)
(setq matched (member tags tagslist))
greboides
rgr: isnt your function working?
ams
that just doesn'tmakesense...
if it isn't a list, you use member, which works on lists..
jordanb
I love it how all the libertarians think "private enterprise" is going to explore space.
rgr
it works fine. I just wanted pointers to better elisp style......
jordanb
BUT MISTER PRIVATE ENTERPRISE MAN! I WANT A PONY! MAKE ME A PONY MISTER PRIVATE ENTERPRISE MAN!
rgr
ams: why does it not make sens? It makes perfect sense. matched is returned if there was ... a match....
greboides
jordanb: that makes sense
ams
rgr: can you show input?
jlf
rgr: it's more idiomatic to return either the first match that was found or nil, instead of setq'ing a state variable
ams
valid input for both cases...
rgr
ams: look at the test function. It is so easy. its either ONE tag or a LIST of tags. e.g "mytag" or '("mytag" "tags")
jordanb
The big thing holding Private Enterprise back is that NASA is a monopoly, of course.
jlf
that's socialized space exploration!
ams
rgr: ok
jordanb
That massive lucerative ET market NASA's monopolizing, boy Private Enterpise would just love to crack it!
ams
sorry, i'm a bit tipsy
rgr
jlf: I know. I could cry now. LOook, I didnt know about the return you and said I needed cl for that. hgence the throw to escape after the first match.
lol
jlf
let's have an old-fashioned #emacs intervention for ams
damd
don't use `return'
rgr
ok, I give up. Not one bit of concensus ;) It works. I did it and I am happy ... time to move on .. cheers guys ;)
damd
we did reach some sort of consensus, but you didn't agree with it :/
jlf
return is fine to terminate (loop ...) prematurely
ams
(if (nlistp tags)
(setq matched (member tags tagslist))
(mapc (lambda (x)
(when (member x tagslist) (setq matched t)))
tags)))
i'd write itlike that.
jlf
many people consider #'loop itself harmful, but that's another story
rgr
damd: no. You did not. You said "use recursion" someone else said looping IS recursion. I suggested looping in the context of dolist as defined in my book is NOT recursion. There was no concensus at all.
jordanb
loop is insufficently lispertarian
rgr
ams: ok will look at map. did wonder if that would come into it.
jordanb
(Action) lobs some doung around.
ams
the lists in question are so small that it is not worth the effort to break early.
jordanb
dung
jlf
(Action) wonders if arc implements lp
ams
rgr: and (when .. (progn ..)) .. redundant.
rgr
yup
brb
jordanb
Arc implements paul graham ma******ting.
ams
jordanb: please move this elsewhere.
damd
does xah lee approve of arc?
jlf
jordanb: ams is a stickler for decorum
jordanb
Heh.
rgr
ams: sorry, can you repost that mapc example please accidentally closed the window.
damd
,t8 en sv decorum
rudybot
decorum
fsbot
decorum
jordanb
I thought xah was a fan of Matlab, or something.
rgr
oh no. My satsumas are full of pips. Disaster.
kodein
at least it's not a hovercraft full of eels.
« prev 1 2 3 4 5 6 7 8 9 10 next »