Re: Checksum (noob)



"atgraham@xxxxxxxxx" <atgraham@xxxxxxxxx> writes:

Lisp version:

(defun checksum (lst)
(logand (- 0 (apply '+ lst)) #xff))

I like it. However, I'm wondering if it's appropriate to be paranoid
about a user passing invalid parameters to such a function (lists of
lists, integers, etc.) and causing havoc at runtime.

Document the proper parameters. If people violate the specification,
they rightly land in the debugger.

Also, "lst" is a bad name for a parameter that is a list. "list" would
be better, if no more suitable name is appropriate.

http://www.cs.northwestern.edu/academics/courses/325/readings/graham/graham-notes.html
has some examples of other things from ANSI Common Lisp to avoid.

I've been looking over Graham's book, and he stresses the importance of
indentation. Traditionally, I've shunned emacs, since it seems to get
*all* default behavior wrong, in every situation, ...

Not true.

Alas, it gets the indentation wrong, or at least it's different
than what Graham suggests (for example, in "if" expressions, it indents
the "then" differently than the "else"). Is there a configuration
parameter that I can use to fix it?

(setq lisp-indent-function 'common-lisp-indent-function) is a quick
way. You can make it more specific to CL buffers, but if you don't
edit a lot of elisp, you don't have to worry much about it. Google
should give you some examples with which to work.

I also noticed that gcl will accept a dotted list as a parameter to
checksum, but clisp will not. What's the correct behavior?

I don't see where in the hyperspec that a proper list is required, but
I didn't look especially hard.

Zach

.



Relevant Pages

  • Re: positioning in ordered lists
    ... The default indentation for both is 40 pixels, in common practice, though lists look different because of the numbers. ... Thus, you could set all the margins and paddings to zero _except_ margin-left for, which should be set to a value that is sufficient for the number, the period, and the spacing before the list item content. ... Please don't use CSS properties without reading and understanding their _meaning_ ...
    (alt.html)
  • Re: Outline view: How to control amount of indentation?
    ... (as defined in the Paragraph dialog box), while indentation for numbered ... Stefan Blom wrote: ... Paragraph dialogue box and Outline Numbered Lists do not apply to ...
    (microsoft.public.word.docmanagement)
  • Re: template is dropping paragraph formatting
    ... indentation of outline-numbered lists is problematic in several ... But I'm willing to give it a try, since I need to distrubute this template ...
    (microsoft.public.word.docmanagement)
  • Lists that are flush left
    ... I'm trying to set things up in LaTeX such that lists (using the ... line indentation, that is). ... the bullet is vertically aligned with the start of the ... nested lists to have extra margins, ...
    (comp.text.tex)
  • Re: Add new li dynamically adds indentation in IE
    ... The "li" should be with 0 indentation. ... When I dynamically add it (Javascript) - in IE it's ALWAYS ... I've never seen the problem and I script a lot of lists. ... Try a css rule ...
    (comp.lang.javascript)