Search found 12 matches

by sepuku
Thu May 03, 2012 4:47 pm
Forum: Scheme
Topic: write to a non existing file
Replies: 1
Views: 9057

write to a non existing file

I have written a version to write to an existing file: ;; write to an existing file (define write-to-a-file (lambda (path txt) (call-with-output-file path (lambda (output-port) (write txt output-port))))) I want to implement a version that checks if the file exists then the text is added to the file...
by sepuku
Fri Nov 25, 2011 2:20 pm
Forum: Common Lisp
Topic: find list in a list function
Replies: 6
Views: 8343

Re: find list in a list function

Or if you prefer loops you could also use: (The proposed recursive version should be tail-recursive, but if you're unlucky with your compiler/interpreter it may blow the stack for very large lists) (defun sublist-p (list) (loop for el in list for sublist-p = (consp el) do (when sublist-p (return t)...
by sepuku
Mon Nov 21, 2011 5:09 am
Forum: Common Lisp
Topic: find list in a list function
Replies: 6
Views: 8343

Re: find list in a list function

Ahh yes,thank you very much for your replies.I'll check and choose which version i prefer. :mrgreen:
by sepuku
Sun Nov 20, 2011 8:46 am
Forum: Common Lisp
Topic: find list in a list function
Replies: 6
Views: 8343

Re: find list in a list function

Ahhh thanks,your version works fine.But is there a way to achieve it without some?I'm asking for educational reasons.I'm asking from ansi common lisp book and so far "i've not being taught some" so there must be a way to do it without some.

Thanks for your help so far. :)
by sepuku
Sat Nov 19, 2011 3:56 pm
Forum: Common Lisp
Topic: find list in a list function
Replies: 6
Views: 8343

find list in a list function

Hello people,i'm trying to define a function that takes a list as an argument and returns true if one of its elements is a list. My function for some reason always returns nil. I'm using the listp predicate whichs returns true if something is a list but so far i fail to make it work as i want. (defu...
by sepuku
Thu Nov 17, 2011 6:23 pm
Forum: Scheme
Topic: Questions In Matrix Multiplication
Replies: 5
Views: 18771

Re: Questions In Matrix Multiplication

First of all i'm really sorry for the late answer.But i study and write code in my free time and i have not much lately.

Secondly i want to thank you for the posted paradigms.Although it should be obvious,before your post it wasn't. :D

Once again thank you for your time. :mrgreen:
by sepuku
Thu Nov 10, 2011 11:31 am
Forum: Scheme
Topic: Questions In Matrix Multiplication
Replies: 5
Views: 18771

Re: Questions In Matrix Multiplication

Ahhh wrong!!! It's not (map * row), it's (map * row column).

But is my substitution correct? :roll:
by sepuku
Thu Nov 10, 2011 7:18 am
Forum: Scheme
Topic: Questions In Matrix Multiplication
Replies: 5
Views: 18771

Re: Questions In Matrix Multiplication

First of all thank you for your reply. :) Thank you for exaplaining the map procedure.So far i was not aware that the number of arguments of map depend on the procedure we map.(although i should :oops: ) Now this gives birth to a new question : The multiplication operator accepts any number of argum...
by sepuku
Wed Nov 09, 2011 3:48 pm
Forum: Scheme
Topic: help writing a max procedure
Replies: 4
Views: 14512

Re: help writing a max procedure

I'm still a learner but shouldn't you use a parenthesis in (define ( my-max ... ( I mean before 'my-max'.) Also my second question might be silly but i'll ask anyway. I believe that you don't have both procedures in the same file.Right?Cause if you are not then there could be some name conflict ... ...
by sepuku
Wed Nov 09, 2011 3:28 pm
Forum: Scheme
Topic: Questions In Matrix Multiplication
Replies: 5
Views: 18771

Questions In Matrix Multiplication

Hello there i have managed to multiply matrices with this(as shown at rosetta code): (define (matrix-multiply matrix1 matrix2) (map (lambda (row) (apply map (lambda column (apply + (map * row column))) matrix2)) matrix1)) where my map looks like this: ;;map: act to a list with a procedure ;;proc ---...