Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
all good things come to an end

Adbot
ADBOT LOVES YOU

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

rotor posted:

finding the end of an array is an exceptional condition

so what you're saying is that it works best if the enumeration loop knows what it's enumerating over, so you can have one version for arrays and other bounded collections and one for IO that reads until exhausted, but both present the same API to higher-level code so you don't have to care?

JawnV6
Jul 4, 2004

So hot ...
but then you get the movies

and janeway is an admiral!?!?!?

makes no sense

tef
May 30, 2004

-> some l-system crap ->
man I can't wait to find out what happens when this thread discovers the semipredicate problem :q:

Sneaking Mission
Nov 11, 2008

tef posted:

man I can't wait to find out what happens when this thread discovers the semipredicate problem :q:

that's pretty much php_library.txt

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Panic! At The cisco posted:

that's pretty much php_library.txt

i assume you say this because that is a completely solved problem in php?

(also mega lol @ exceptions when you hit the end of a loop. python is such a bad language)

skeevy achievements
Feb 25, 2008

by merry exmarx

BonzoESC posted:

so what you're saying is that it works best if the enumeration loop knows what it's enumerating over, so you can have one version for arrays and other bounded collections and one for IO that reads until exhausted, but both present the same API to higher-level code so you don't have to care?

I think his point is traversing a finite collection and finding the end isn't exceptional behaviour, it's expected behaviour

use the same API for I/O if you like but obviously reaching the end of a stream could be expected (web request) or exceptional (market data stream) depending on the application

tef posted:

man I can't wait to find out what happens when this thread discovers the semipredicate problem :q:

I think capn crunch showed in-band signaling is a bad idea

skeevy achievements fucked around with this message at 16:27 on May 18, 2012

Sneaking Mission
Nov 11, 2008

Tiny Bug Child posted:

i assume you say this because that is a completely solved problem in php?

(also mega lol @ exceptions when you hit the end of a loop. python is such a bad language)

yeah

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

BonzoESC posted:

so what you're saying is that it works best if the enumeration loop knows what it's enumerating over, so you can have one version for arrays and other bounded collections and one for IO that reads until exhausted, but both present the same API to higher-level code so you don't have to care?
this is how python works, fyi

the api they're complaining about is the one for IO

Shaggar
Apr 26, 2006
python does it wrong always

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Janin posted:

this is how python works, fyi

the api they're complaining about is the one for IO

nah they're at a lower level if they have to worry about exceptions from the array ending

or does python have some kind of __~^each^~__(array, lambda{but only one expression}) function with a terrible name and tenuous object-orientedness?

GameCube
Nov 21, 2006

Shaggar posted:

python does it wrong always

this is getting pretty old, this isn't even shaggaring anymore. put some effort into it

Shaggar
Apr 26, 2006
actually what gets old is people suggesting that python isnt total trash for idiots

penus de milo
Mar 9, 2002

CHAR CHAR

tef posted:

man I can't wait to find out what happens when this thread discovers the semipredicate problem :q:

semipredicate yourself back to gbs

Share Bear
Apr 27, 2004

Shaggar posted:

actually what gets old is people suggesting that python isnt total trash for idiots

GIT-R-DONE!!

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

BonzoESC posted:

nah they're at a lower level if they have to worry about exceptions from the array ending

or does python have some kind of __~^each^~__(array, lambda{but only one expression}) function with a terrible name and tenuous object-orientedness?
Python's compiler special-cases iteration over fixed-size sequences, so it uses a more efficient internal mechanism.

Iterators are for when you're looping over a value which doesn't have a fixed size, and might need to perform arbitrary IO to calculate the next element.

And why would you ever want a lambda with more than one expression? If you really need to use statements in a loop for some horrible reason, just define a local procedure.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Janin posted:

And why would you ever want a lambda with more than one expression? If you really need to use statements in a loop for some horrible reason, just define a local procedure.

Because using lambdas/blocks/anonymous functions as a building block for control structures is convenient

code:
class CalculatorTest < Test::Unit::TestCase
  context "a calculator" do
    setup do
      @calculator = Calculator.new
    end

    should "add two numbers for the sum" do
      assert_equal 4, @calculator.sum(2, 2)
    end

    should "multiply two numbers for the product" do
      assert_equal 10, @calculator.product(2, 5)
    end
  end
end

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
In Python, it's more idiomatic to use existing control structures like 'if' or 'with', rather than inventing your own ad-hoc.

code:
with context("a calculator") as c:
  with c.setup():
    calculator = Calculator()

  with c.should("add two numbers for the sum"):
    assert_equal(4, calculator.sum(2, 2))

  with c.should("multiply two numbers for the product"):
    assert_equal(10, calculator.product(2, 5))
If multi-line closures are really the best solution to some problem, then you're probably doing something complicated, and shouldn't mind naming your closures.

tef
May 30, 2004

-> some l-system crap ->

Janin posted:

In Python, it's more idiomatic to use existing control structures like 'if' or 'with', rather than inventing your own ad-hoc.

If multi-line closures are really the best solution to some problem, then you're probably doing something complicated, and shouldn't mind naming your closures.

Would kill for a 'where' construct though, so I could restrict the scope of the defined statements.

That and real lexical scope.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Janin posted:

In Python, it's more idiomatic to use existing control structures like 'if' or 'with', rather than inventing your own ad-hoc.

Oh yeah, Ruby doesn't have "with" built-in; implementing it is an exercise for the reader https://github.com/meh/ruby-with/blob/master/lib/with.rb

coaxmetal
Oct 21, 2010

I flamed me own dad

Werthog posted:

this is getting pretty old, this isn't even shaggaring anymore. put some effort into it

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

BonzoESC posted:

Oh yeah, Ruby doesn't have "with" built-in; implementing it is an exercise for the reader https://github.com/meh/ruby-with/blob/master/lib/with.rb

What book/resource would you recommend for learning the details of ruby? It seems like a really cool language and I only know the basics atm

skeevy achievements
Feb 25, 2008

by merry exmarx

BonzoESC posted:

Oh yeah, Ruby doesn't have "with" built-in; implementing it is an exercise for the reader https://github.com/meh/ruby-with/blob/master/lib/with.rb

clojure owns for this, I decided the language needed a switch statement based on regexes and so I added it, took about 15 lines of code

tef how on a scale of 1-10 how much do you sneer at domain specific languages implemented in lisp dialects

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Sweeper posted:

What book/resource would you recommend for learning the details of ruby? It seems like a really cool language and I only know the basics atm

i never really used a book or a blog post about "metaprogramming"

work with some libraries that use ruby cleverly and read their source

if in doubt read the C source or the rubinius (ruby in ruby) source

if still in doubt ask someone

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug
gently caress ruby, i'm using objectivist-c for my new bitcoin miner

Toady
Jan 12, 2009

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
looooool crosspost that in the pic thread man

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Toady posted:



goddamnit... we actually get a handful of women in our clojure meet ups and it's very cool to see them not shunned and degraded.

no one has been a tool bag to any of them (at least not in front of me or to their face), thank the baby jesus

JawnV6
Jul 4, 2004

So hot ...

Otto Skorzeny posted:

i like this nomenclature of just directly calling them quantitative and qualitative btw. the common custom of calling one h&p and the other p&h is annoying

finally found my copy of quant to confirm this, but im old and used quant 3rd edition when they were still listed as "H&P" and i assume there's been some big academic :qq: because hennessy went into "management" while patterson stayed technical but idk if thats true

salted hash browns
Mar 26, 2007
ykrop
seriouspostin:

I haven't programmed in Java for a while and have a data structures related question.

I have a ton of lines of the following types: [date, double] I want stored in some sort of list. This list I will never access randomly, I will only add to the end of it and access the list from beginning to end, one at a time.

In addition, I will have 100s of these types of lists I want to access programatically.

What data structure is best optimized for this type of usage?

tia

salted hash browns fucked around with this message at 23:25 on May 18, 2012

Shaggar
Apr 26, 2006
Java List datatype picking flowchart:
Do you want a List?
y -> Use ArrayList

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Shaggar posted:

Java List datatype picking flowchart:
Do you want a List?
y -> Use ArrayList

Shaggar was right

This is like the only uses case for LinkedList, but frankly I don't think it will matter which of the two you choose.

time is a wastin
Sep 11, 2011

Toady posted:


kill every white male computer professional

salted hash browns
Mar 26, 2007
ykrop

MEAT TREAT posted:

Shaggar was right

This is like the only uses case for LinkedList, but frankly I don't think it will matter which of the two you choose.

wait am I missing something, how do I do myArrayList.add(myDate, myDouble); ?

salted hash browns fucked around with this message at 23:32 on May 18, 2012

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

iamthexander posted:

wait am I missing something, how do I do myArrayList.add(myDate, myDouble); ?

lol you need to make a container object to put into the list

or add them two at a time and traverse the list in double increments whatever

salted hash browns
Mar 26, 2007
ykrop

Sweeper posted:

lol you need to make a container object to put into the list

or add them two at a time and traverse the list in double increments whatever

eff i thought there was some magic i could do

also what do you mean traverse the list in double increments

Police Academy III
Nov 4, 2011
ya, you've got to spend like 6 lines of code just to make some dumb class to hold 2 values and then 8 more lines for getters + setters if you don't want to piss off the java oop sperg gods. basically what im saying is that java is terrible.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

iamthexander posted:

seriouspostin:

I haven't programmed in Java for a while and have a data structures related question.

I have a ton of lines of the following types: [date, double] I want stored in some sort of list. This list I will never access randomly, I will only add to the end of it and access the list from beginning to end, one at a time.

In addition, I will have 100s of these types of lists I want to access programatically.

What data structure is best optimized for this type of usage?

tia

arraylist might not be the best unless you know the sizes up front, do you know how big your lists need to be?

can also use a generic Pair<U,T> class: http://code.google.com/p/totallylazy/source/browse/src/com/googlecode/totallylazy/Pair.java?r=ddc97667f03784cbf4db4906d2d09777926d0a17

salted hash browns
Mar 26, 2007
ykrop

trex eaterofcadrs posted:

arraylist might not be the best unless you know the sizes up front, do you know how big your lists need to be?

can also use a generic Pair<U,T> class: http://code.google.com/p/totallylazy/source/browse/src/com/googlecode/totallylazy/Pair.java?r=ddc97667f03784cbf4db4906d2d09777926d0a17

I do, ~23500 items.

Thinking LinkedArray might actually be the best here since I never need random access and only need to iterate through the whole thing. Any benefits to using a Pair class over creating my own shell class?

Also new step: now lets say I have the following objects:

code:
LinkedList myList1;
LinkedList myList2;
...
LinkedList myListn;
Where should I toss those Lists so I can access them programatically by their names (something like 'return yosposArrays["myList17"];' or 'hashmap.get("blah"')?

salted hash browns fucked around with this message at 00:06 on May 19, 2012

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

reallyprettymad posted:

kill every white male computer professional


  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply