I'm just trying to understand basic stuff.
say I have a local list called "myList" (assigned using 'let' . . .
should I have used something else?)  Who cares what's in it.  Maybe I
set it up from a list comprehension from some input to my function.

I have no idea how to iteratively mess with it since everything is
persistent.  Ok, like, say it's a list of lists and I am going to be
merging the lists, like Tarjan's mergesort from some book from
college.

so I have myList with contents [[11] [2] [4] [1] [99]]

here's how I would do it in python:

def msort(myList):
  myList = [[x] for x in someList]
  while len(myList) > 1:
    l1 = myList.pop(0)
    l2 = myList.pop(0)
    listmerge = some_merge_function(l1, l2)
    myList.append(listmerge)          # important that newly merged go
to back of queue to get proper runtime
  return myList[0]

here's what I'm trying to do for clojure, and it's a mess:

(defn msort [toSort]
  (def sorted (let
   [myList (for [x toSort] [x])]      <----- so far so good (not a
real comment.  I don't know how, yet)
   [
    (while (> (count myList) 1)      <------- infinite loop the way
written?  I don't know how to overwrite myList
      (let [l1 (nth myList 0)][])
      (let [l2 (nth myList 1)][])
      (let [listmerge (some_merge_func l1 l2)][])
      (let [myList (concat (drop 2 myList) listmerge)][myList])  <---
probably a different local variable
      )
   ]))
  sorted)

doesn't compile anyway . . . I see that the let is causing the scope
to be all screwed up.  l1 and l2 can't be seen for the merge function.

should I be using let at all here?  Can things be redefined using
def?  see how much simpler it is not to say anything?  Which is
it .... def or let in python?  Answer: No . . .but I'm sure there's
value.  This seems like something that might be in the FAQ. . . .or
somewhere back in these discussions.  I'll look around.

Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to