nila_joy Posted November 15, 2011 Share Posted November 15, 2011 Hi.. as I told before, I am a beginner in LISP, trying to write something, but getting error.. "error: malformed list on input" . what it means? I have list :- ((((1 . x ) (2 . y)) ((3 . z) (4 . a))) (((1 . m ) (2 . n)) ((3 . o) (4 . p))))) I want this as :- (((x y) (z a)) ((m n) (o p))) (defun test1 () (setq gb '((((1 . x ) (2 . y)) ((3 . z) (4 . a))) (((1 . m ) (2 . n)) ((3 . o) (4 . p))))) (setq blanka '()) (setq blankb '()) (setq len1 (length gb)) (setq count1 0) (while ( (setq data1 (nth count1 gb)) (setq len2 (length data1) (setq count2 0) (while ( (setq data2 (nth count2 data1)) (setq blankb (append blankb (list data2))) (setq count2 (1+ count2)) ) ; while (setq blanka (append blanka (list data1))) (setq count1 (1+ count2)) ) ;while ) Quote Link to comment Share on other sites More sharing options...
resullins Posted November 15, 2011 Share Posted November 15, 2011 It means your parenthesis don't match. You have to have the same number of open parenthesis as closed. That's why LISP stands for "Lost in Stupid Parenthesis." Also, you're new, so you get a pass, but you need to wrap any and all code your post here in the code tags (the button that looks like a pound sign). Then your code will look like this. Quote Link to comment Share on other sites More sharing options...
nila_joy Posted November 15, 2011 Author Share Posted November 15, 2011 sorry..I don't know the tagging process.. how I use code tag? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 15, 2011 Share Posted November 15, 2011 Maybe this troubleshooter will help you in the future. Also, as resullins states, enclose your code in code tags: [noparse] [/noparse][/color][color=darkgreen]Your code here[/color][color=red][noparse] [/noparse] Quote Link to comment Share on other sites More sharing options...
SLW210 Posted November 15, 2011 Share Posted November 15, 2011 sorry..I don't know the tagging process.. how I use code tag? CODE POSTING GUIDELINES Quote Link to comment Share on other sites More sharing options...
resullins Posted November 15, 2011 Share Posted November 15, 2011 @nila_joy: Don't pay attention to SLW210... he really hates people that miss his rules! Now, you know for next time! Quote Link to comment Share on other sites More sharing options...
nila_joy Posted November 15, 2011 Author Share Posted November 15, 2011 Hi.. as I told before, I am a beginner in LISP, trying to write something, but getting error.. "error: malformed list on input" . what it means? I have list :- ((((1 . x ) (2 . y)) ((3 . z) (4 . a))) (((1 . m ) (2 . n)) ((3 . o) (4 . p))))) I want this as :- (((x y) (z a)) ((m n) (o p))) (defun test1 () (setq gb '((((1 . x ) (2 . y)) ((3 . z) (4 . a))) (((1 . m ) (2 . n)) ((3 . o) (4 . p))))) (setq blanka '()) (setq blankb '()) (setq len1 (length gb)) (setq count1 0) (while (< count1 len1) (setq data1 (nth count1 gb)) (setq len2 (length data1) (setq count2 0) (while (<count2 len2) (setq data2 (nth count2 data1)) (setq blankb (append blankb (list data2))) (setq count2 (1+ count2)) ) ; while (setq blanka (append blanka (list data1))) (setq count1 (1+ count2)) ) ;while ) Quote Link to comment Share on other sites More sharing options...
nila_joy Posted November 15, 2011 Author Share Posted November 15, 2011 got it man.. actually I was playing Company of heroes,but hanged when got ur msg .. ur words made it man Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 15, 2011 Share Posted November 15, 2011 Consider this function: (setq l '((((1 . x ) (2 . y)) ((3 . z) (4 . a))) (((1 . m ) (2 . n)) ((3 . o) (4 . p))))) (mapcar (function (lambda ( a ) (mapcar (function (lambda ( b ) (mapcar 'cdr b)) ) a ) ) ) l ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 15, 2011 Share Posted November 15, 2011 Consider this function: (setq l '((((1 . x ) (2 . y)) ((3 . z) (4 . a))) (((1 . m ) (2 . n)) ((3 . o) (4 . p))))) (mapcar (function (lambda ( a ) (mapcar (function (lambda ( b ) (mapcar 'cdr b)) ) a ) ) ) l ) HaHa, I was just about to post this: (defun foo (lst) (mapcar '(lambda (a) (mapcar '(lambda (b) (mapcar 'cdr b)) a)) lst) ) Quote Link to comment Share on other sites More sharing options...
nila_joy Posted November 15, 2011 Author Share Posted November 15, 2011 Thnx resu.. "SLW-the Last hero" is under surveillance , but how should I rectify my error ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.