Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

What good are trees?

Name: Anonymous 2010-05-28 14:55

I've never had to use them.

Name: Anonymous 2010-05-28 15:07

I use them all the time

Name: Anonymous 2010-05-28 15:07

>>1
they smell good and you can pick fruits and stuff of them.
you should go more outside.

Name: Anonymous 2010-05-28 15:08

They're good for making paper, for one thing.

Name: Anonymous 2010-05-28 15:10

trees are used to group data for fast lookup.

*b-trees are used in sql databases to make greater than less than lookups work quickly.
*r-trees are used for spatial indexing.
*distributed hash tables can provide fast lookup of peers in a decentralized network by organizing nodes into a tree.

Name: Anonymous 2010-05-28 15:18

>>5
And how are those better than basic hash tables?

Name: Anonymous 2010-05-28 15:19

Surely you must have breathed Air/oxygen which was produced/recycled from CO2 by trees through photosynthesis.

Name: Anonymous 2010-05-28 15:30

>>7
* algae

Name: J 2010-05-28 15:34

They are used in some compression algorithms
http://en.wikipedia.org/wiki/Huffman_coding

Name: Anonymous 2010-05-28 16:06

So, to sum this up:

Trees are useful in very special circumstances, you never need to know them for general tasks and when you need them you'll find an implementation easily.

Name: Anonymous 2010-05-28 16:12

What good are strings?

I've never had to use them.

Name: Anonymous 2010-05-28 16:38

So, to sum this up:

Numbers are useful in very special circumstances, you never need to know them for general tasks and when you need them you'll find an implementation easily.

Name: Anonymous 2010-05-28 16:42

>>11
you've never had to use sequences of numbers?

Name: Anonymous 2010-05-28 17:10

>>13
If you are using strings for that instead of an array/list of numbers, then you are a moron (or an erlang user)

Name: Anonymous 2010-05-28 19:06

>>14
if you are using something for strings other than sequences of characters and something for characters other than sequences of bits (which are numbers), then you are a moron (or using a quantum computer, but then you have infinitely many problems).

Name: Anonymous 2010-05-28 19:15

>>1
They helped to make the best hardcover book of all time. SICP.

Name: Anonymous 2010-05-28 19:21

>>15
I see this has gotten out of hand. >>11 was me taking the piss out of >>1. In >>14 I was talking about the general case of needing a representation of a sequence of numbers (which a string like "12 13 14" is a poor data structure for), and not how strings are implemented in your computer. I hope thats cleared everything up

Name: Anonymous 2010-05-28 19:52

>>17
But >>13 never suggested converting a string of numbers into a longer string of digits and spaces, so why would you bring that up?

Name: Anonymous 2010-05-28 20:00

>>18
the way I interpreted his post was as an answer to the question "what good are strings". Therefor "you've never had to use sequences of numbers?" seemed to me as if he was suggesting, "strings are good for representing sequences of numbers". As for the format, it was an arbitrary decision and could have been represented in a different manner.
And just for the record, I believe that having strings by an array(or list) of numbers a la C (arguably) and erlang, instead of having a separate character type is stupid.

Name: Anonymous 2010-05-28 20:10

>>19
I once tied some cables with strings. Totally useful

Name: Anonymous 2010-05-28 20:24

THAT'S THE JOKE

Name: Anonymous 2010-05-28 20:55

What good are programming languages?

I've never had to use them.

Name: Anonymous 2010-05-28 21:34

>>6
Hash tables let you lookup a single node. Trees let you lookup classes of nodes.

Name: Anonymous 2010-05-28 21:46

LISP doesn't support tree traversal.
It has half a dozen mapping functions for lists, but nothing for lists of lists. I was quite shocked.

Name: Anonymous 2010-05-28 21:55

>>24
The assumption is that you will build the tree functions from the list functions as necessary.

Name: Anonymous 2010-05-28 22:05

Any programmer who can not construct and support their own binary tree structure should turn in their license.

Name: Anonymous 2010-05-28 22:18

>>25
>>24 is right; its actually impossible to work with trees in Lisp, since it doesn't support recursion derp derp derp

Name: Anonymous 2010-05-28 22:32

>>24
It has quite a few actually, it seems you haven't read your Hyperspec.

Name: >>28 2010-05-28 22:33

Not that writing your own is hard. Most of the time when you're using trees, you want to do fairly specific things.

Name: Anonymous 2010-05-28 22:43

>>28
I did actually and found nothing of that sort.
The closest in there are subst and friends.

Name: Anonymous 2010-05-28 23:00

>>30
besides copy-tree and the like, subst/-if/-if-not and related, do let you map over a tree and replace elements selectively.

Mind explaining what kind of functions you'd like to see? Most of the times I needed to work with complex circular lists, I was dealing with graphs and more complex structures, and for those, I needed a full-fledged graph manipulation library (which I did find, altough, the documentation sucked, but was overall easy to use).

Name: Anonymous 2010-05-28 23:26

>>31
I needed something mapcar-like to search for some tags in parsed HTML as returned by closure-html. See http://common-lisp.net/project/closure/closure-html/examples.html for how that looks like.

I ended up writing a recursive function to do it and just wondered why there isn't something like this built into the language when there are lots of other constructs you could also just reinvent on your own but are useful enough to include. Or maybe I'm just missing something obvious.

Name: Anonymous 2010-05-29 3:11

>>22
the story of /prog/

Name: Anonymous 2010-05-29 3:39

What good are hash tables?

I've never had to use them.

Name: Anonymous 2010-05-29 4:22

>>34
They can be useful if you have a lot of data and need a faster way than iteration to look up an element (and you cannot just use regular indexing because the keys are too large).

Name: Anonymous 2010-05-29 4:31

>>19
many languages do have a separate character type, but that character type is almost always an integral type.
in haskell this is not the case, until you do something like this:
both :: Arrow a => a b c -> a (b, b) (c, c)
both = join (***)

instance Num Char where
    fromInteger = chr . fromInteger
    (+) = ((chr . flip mod (ord maxBound + 1) . uncurry (+)) .) . curry (both ord)
    (*) = ((chr . flip mod (ord maxBound + 1) . uncurry (*)) .) . curry (both ord)
    (-) = ((chr . flip mod (ord maxBound + 1) . uncurry (-)) .) . curry (both ord)
    negate = chr . (ord maxBound + 1 -) . ord
    abs = id
    signum = chr . signum . ord

instance Real Char where
    toRational = toRational . ord

instance Integral Char where
    quotRem = ((both chr . uncurry quotRem) .) . curry (both ord)
    toInteger = toInteger . ord


too bad schemers are stuck with their http://en.wikipedia.org/wiki/Scheme_(programming_language)#Disjointness_of_primitive_datatypes.

Name: Anonymous 2010-05-29 11:08

>>36
It's not like Haskells solution is much better, really, since all you are doing is performing a type conversion before each (primitive number) operation and informing the type system that "it's cool bro". If the cost wasn't so minimal, you'd be better off converting once, doing your number operations and then converting back, which is what I'd do in Scheme (Yes, i fully accept it's cheating the type system). If we could agree on a method for doing generic functions, I imagine we could get a solution similar to the Haskell one, but getting Schemers to agree is....yeah.
On a separate note, with that solution can you intermix it with other Numeric types? I was under the impression that you couldn't mix types within a typeclass instance. So, with your solution I imagine that you can't do 'I' + 3 and get 'L'. Or will Haskell "do the right thing" as it does for other cases where you intermix numbers?

Name: Anonymous 2010-05-29 12:38

>>33
Lurk more.

Name: Anonymous 2010-05-29 13:08

What good is BBCode?

I've never had to use it.

Name: Anonymous 2010-05-29 14:57

>>39
Then you are not an EXPERT PROGRAMMER

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List