Search Results

Search found 2 results on 1 pages for 'cwallenpoole'.

Page 1/1 | 1 

  • Land of Lisp example question

    - by cwallenpoole
    I've read a lot of good things about Land of Lisp so I thought that I might go through it to see what there was to see. (defun tweak-text (lst caps lit) (when lst (let ((item (car lst)) (rest (cdr lst))) (cond ; If item = space, then call recursively starting with ret ; Then, prepend the space on to the result. ((eq item #\space) (cons item (tweak-text rest caps lit))) ; if the item is an exclamation point. Make sure that the ; next non-space is capitalized. ((member item '(#\! #\? #\.)) (cons item (tweak-text rest t lit))) ; if item = " then toggle whether we are in literal mode ((eq item #\") (tweak-text rest caps (not lit))) ; if literal mode, just add the item as is and continue (lit (cons item (tweak-text rest nil lit))) ; if either caps or literal mode = true capitalize it? ((or caps lit) (cons (char-upcase item) (tweak-text rest nil lit))) ; otherwise lower-case it. (t (cons (char-downcase item) (tweak-text rest nil nil))))))) (the comments are mine) (FYI -- the method signature is (list-of-symbols bool-whether-to-caps bool-whether-to-treat-literally) but the author shortened these to (lst caps lit).) But anyway, here's the question: This has (cond... (lit ...) ((or caps lit) ...)) in it. My understanding is that this would translate to if(lit){ ... } else if(caps || lit){...} in a C style syntax. Isn't the or statement redundant then? Is there ever a condition where the (or caps lit) condition will be called if caps is nil?

    Read the article

  • parse more items

    - by user449891
    Currently I'm using zRSSFeed to parse a Menalto Gallery2 RSS feed, and only get about 5 details: link, description, title, etc. There are about 11 items within the tag. How can I get zRSSFeed to return all of them, including <media:thumbnail url="http..."> which includes a colon? Code from ZRSSFeed var html='';var row='odd';var xml=getXMLDocument(data.xmlString);var xmlEntries=xml.getElementsByTagName('item'); //if(options.header)html+='<div class="rssHeader">'+'<a href="'+feeds.link+'" title="'+feeds.description+'">'+feeds.title+'</a>'+'</div>'; //html+='<div class="rssBody">'+'<ul>';for(var i=0;i<feeds.entries.length;i++){ html+='<div class="rssBody">';for(var i=0;i<feeds.entries.length;i++){ var entry=feeds.entries[i];var entryDate=new Date(entry.publishedDate);var pubDate=entryDate.toLocaleDateString()+' '+entryDate.toLocaleTimeString(); //html+='<li class="rssRow '+row+'">' html+='<div>' //if(options.date)html+='<div>'+pubDate+'</div>' if(options.content){ //if(options.snippet&&entry.contentSnippet!=''){ //var content=entry.contentSnippet; //}else{ var content=entry.content; sq_arr = content.split('>'); sq_brr = sq_arr[0].split('?'); sq_crr = sq_arr[1].split(' width'); sq_drr = sq_crr[0].split('src'); sq_b = new RegExp(/\d+(?=\")/g).exec(sq_drr[1]); sq_c = sq_b*1-1; sq_rplc = sq_brr[1].replace(/\d+(?=\")/g, sq_c); sq_str = sq_brr[0] + '?g2_view=core.DownloadItem&' + sq_rplc + '>' + sq_crr[0] +'" height="75" width="75"></a>'; content = sq_str.r`enter code here`eplace(/&amp;/g, '&'); //} //html+='<p>'+content+'</p>' html+=content //html+='<'+options.titletag+'><a href="'+entry.link+'" title="View this feed at '+feeds.title+'" target="'+options.linktarget+'">'+entry.title+'</a></'+options.titletag+'>' } (A more human readable version -- cwallenpoole) var html=''; var row='odd'; var xml=getXMLDocument(data.xmlString); var xmlEntries=xml.getElementsByTagName('item'); html+='<div class="rssBody">'; for(var i=0;i<feeds.entries.length;i++){ var entry=feeds.entries[i]; var entryDate=new Date(entry.publishedDate); var pubDate=entryDate.toLocaleDateString()+' '+entryDate.toLocaleTimeString(); html+='<div>' if(options.content){ var content=entry.content; sq_arr = content.split('>'); sq_brr = sq_arr[0].split('?'); sq_crr = sq_arr[1].split(' width'); sq_drr = sq_crr[0].split('src'); sq_b = new RegExp(/\d+(?=\")/g).exec(sq_drr[1]); sq_c = sq_b-1; sq_rplc = sq_brr[1].replace(/\d+(?=\")/g, sq_c); sq_str = sq_brr[0] + '?g2_view=core.DownloadItem&' + sq_rplc + '>' + sq_crr[0] +'" height="75" width="75"></a>'; content = sq_str.r`enter code here`eplace(/&amp;/g, '&'); html+=content } // missing }???

    Read the article

1