code logs -> 2009 -> Tue, 10 Mar 2009< code.20090309.log - code.20090311.log >
--- Log opened Tue Mar 10 00:00:34 2009
--- Day changed Tue Mar 10 2009
00:00
< Reiv>
capitalize :: Char -> Char '/n capitalize x '/n | x == head['a'..'z'] = chr ((ord x - 32)) '/n | (How do I do an 'else' statement?)
00:00
< Reiv>
... Okay, so this client doesn't do carriage returns~
00:01
< Reiv>
Otherwise it's workin'. That's a start at least.
00:02
<@Derakon>
Congrats.
00:02
< Reiv>
Well, not really
00:02
< Reiv>
I still need to get it to handle characters /other/ than 'a' - 'z'.
00:03
< Reiv>
But, er, tricksy.
00:03 * Reiv shall depart; answers and advice will be picked up from home.
00:03 Reiv [~82d94c4d@Nightstar-29731.dsl.in-addr.zen.co.uk] has quit [Quit: CGI:IRC (EOF)]
00:28
<@Derakon>
Hrm...Spellcast+ needs a solid separation between player and game state.
00:29
<@Derakon>
Particularly given a) the fact that one of the copies of the game will technically know everything about the board (that being the hosted copy), and b) the fact that spells lie about what they're doing.
00:40 * Derakon renames Spellcast+ to Battlemage for now.
00:41
<@TheWatcher>
Clothieclash! ¬¬
00:45
<@Derakon>
Odd typo: minimimu.
00:45 You're now known as TheWatcher[T-2]
00:46
<@gnolam>
Derakon: a good idea for anything multiplayer anyway.
00:46
<@Derakon>
Yeah.
00:46
<@Derakon>
Fusillade's very incestuous, though.
00:46 * gnolam is quite impressed by how Source handles that, BTW.
00:46
<@Derakon>
Which is?
00:47
<@gnolam>
By magic.
00:47 * Derakon facepalms.
00:47
<@TheWatcher[T-2]>
Based on the way quake did it, iirc~
00:48
<@gnolam>
Source has a strict client/server separation.
00:48
<@gnolam>
So even single-player games are run over loopback.
00:48
<@TheWatcher[T-2]>
(ie: the way quake did it ¬¬)
00:48
<@gnolam>
That is pretty common.
00:48
<@Derakon>
Yeah, that's what I'll be doing in Battlemage too.
00:48
<@gnolam>
But it's the way they implemented the infrastructure for it that impresses me.
00:49
<@Derakon>
It's just that the player running the host gets to communicate with it in a slightly more direct fashion than the other players, who must use the network.
00:50 You're now known as TheWatcher[zZzZ]
00:50
<@gnolam>
Want a variable in an entity replicated to the client? Just implement add it as a CNetworkVar( type, variable_name ) instead of a type variable_name, add one single macro to its data description table, and everything is handled automagically by the engine.
00:50
<@gnolam>
-implement
00:51
<@gnolam>
It even does transparent compression.
00:51
<@Derakon>
Nice.
00:51
<@Derakon>
Too generic for my purposes, but sounds pretty awesome.
00:51
<@Derakon>
("Too generic" meaning I'd go nuts if I tried to implement it myself)
00:51
<@gnolam>
And hinting.
00:52 * TheWatcher[zZzZ] has this nasty habit of making everything as generic as he can up front, so he can reuse it all over... notes this tends to end up with him implementing complex reusable systems, and very little game most of the time >.>
00:53
<@Derakon>
Yeah, see, my first gaming project, Niobium, was a complex, generic system.
00:53
<@Derakon>
I spent three years on it and didn't make any actual games.
00:53
<@gnolam>
Will the value of the variable change often (i.e. just about every frame)? Add the SPROP_CHANGES_OFTEN flag to the data description table and it will be sent every frame. Otherwise, it'll be sent only ever n frames to conserve network traffic.
00:54
<@Derakon>
Battlemage does "chunky" network updates -- the host will send the entire game state to each player, but only rarely.
00:54
<@Derakon>
That's what I get for turn-based gameplay.
00:55
<@gnolam>
The data description tables also transparently handle stuff like game saves and the like.
00:55
<@gnolam>
Source is, for the most part, C++ Done Right.
00:56
<@gnolam>
It's just a shame it completely lacks documentation. :P
00:57
<@Derakon>
Heh.
00:57
<@Derakon>
I made documentation for Fusillade~
00:58
<@Derakon>
Hm. It occurs to me that if I added some way to refer to other bullets other than the parent bullet, it would probably be possible to code in BulletML. Like, it'd be Turing-complete.
00:59
<@Derakon>
You're 20 hours off, dearie.
00:59
<@Derakon>
Mischan.
01:02
<@McMartin>
Well, you can perform computation with Life automata.
01:06 * Derakon nods.
01:06 Derakon is now known as Derakon[AFK]
01:11
<@Vornicus>
You wouldn't /want/ to, but...
01:26 EvilDarkLord [~jjlehto3@Nightstar-9591.cs.hut.fi] has quit [Ping Timeout]
01:29 EvilDarkLord [~jjlehto3@Nightstar-9591.cs.hut.fi] has joined #code
01:30 EvilDarkLord is now known as NSGuest-761
01:46 Derakon[AFK] is now known as Derakon
02:13 gnolam [lenin@Nightstar-1382.A163.priv.bahnhof.se] has quit [Quit: Z?]
02:21 * Vornicus eyes P:tB
02:21
<@Vornicus>
Why have all my guys forgotten how to harvest wood?
02:22
<@Vornicus>
or rather, forgotten how to do so without me telling them to? My village is stagnating because nobody is upgrading!
02:50
<@McMartin>
P:tB?
02:50
<@McMartin>
Planescape: the Battling?
02:50
<@Derakon>
Populous: the Beginning.
02:50
<@Derakon>
Assuming he's playing the game he was playing earlier.
02:55 * Derakon snerks at http://www.smbc-comics.com/index.php?db=comics&id=1429#comic
02:55
<@Vornicus>
What Der said.
02:56
<@Vornicus>
P:tB is an RTS from 1998 by Bullfrog (same guys who did Dungeon Keeper).
02:56
<@Vornicus>
I have ranted on it before.
02:56
<@Vornicus>
Suffice it to say that the unit AI is even more abysmal than I thought.
03:03 hillbillyred [~notmine@Nightstar-24564.range86-151.btcentralplus.com] has joined #code
03:03
< hillbillyred>
hi
03:04
< hillbillyred>
good eve
03:04 hillbillyred [~notmine@Nightstar-24564.range86-151.btcentralplus.com] has left #code []
03:43
<@Derakon>
Mmmph...I like the idea of Battlemage. I'm just concerned about my ability to make money off of a game that focuses on multiplayer.
03:43
<@Derakon>
(And also there's the implied assumption that I'll need to make an AI to play for when you can't do multiplayer)
03:44
<@ToxicFrog>
So make it for fun.
03:44
<@Derakon>
That's a bit at odds with my desire to become a self-sufficient independent game developer.
03:45
<@Derakon>
And of course, there's also my desire to leap into making Jetblade~
03:48
<@ToxicFrog>
Heh.
03:48
<@ToxicFrog>
Which reminds me, I should play Iji.
03:48
<@Derakon>
You should!
03:49
<@ToxicFrog>
But first, rewriting the Glade bindings I'm using for gtkcast.
03:49
<@ToxicFrog>
...again.
04:15 Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Quit: <Insert Humorous and/or serious exit message here>]
05:02 Syloqs-AFH [Syloq@Admin.Nightstar.Net] has quit [Connection reset by peer]
05:35 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has quit [Ping Timeout]
05:50 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code
05:50 mode/#code [+o ToxicFrog] by ChanServ
06:11 Vornicus [~vorn@Admin.Nightstar.Net] has quit [Quit: ]
06:32 Derakon is now known as Derakon[AFK]
06:42 AnnoDomini [~farkoff@Nightstar-29326.neoplus.adsl.tpnet.pl] has joined #Code
06:42 mode/#code [+o AnnoDomini] by ChanServ
07:07
<@McMartin>
I... er... um.
07:07
<@McMartin>
vim has a wikia page.
07:07
<@McMartin>
http://vim.wikia.com/wiki/Main_Page
07:08
<@AnnoDomini>
With over sixteen hundred articles.
07:58 * McMartin also crackles with eldritch power
07:59
<@McMartin>
I may have to write something up for cs_lectures at some point
07:59
<@McMartin>
Though it's going to be much more of a "here's how to do stuff" and more of a "contemplating the Mysteries" post.
07:59
<@McMartin>
After I ensure I got it right.
07:59 * McMartin believes he just re-derived how to do recursion with nothing but lambda expressions.
08:57 You're now known as TheWatcher
09:10
<@TheWatcher>
MxM: you do realise that probably makes you completely unhinged, right? ¬¬
09:12
<@TheWatcher>
As are my fingers, apparently
09:18
< Moltare>
hnghgnghbl. I must have looked at a dozen tutorials on this httprequest thing, each of which gives a different solution, half of which involve editing the server preferences, 90% of the rest involve arcanistry with the user prefs.js and the other 10% don't apply ;_;
09:19
<@TheWatcher>
Ugh
09:21
< Moltare>
(I note that the trick with the user prefs would be excellent but I can't ask every single end-user to fiddle with javascript code to make my product work, which is sad ¬¬)
09:22
<@TheWatcher>
Given that, IME, unless you're targetting an unusual group, you're going to have to ask 75%+ of them to use a different browser anyway...
09:23
< Moltare>
They use Firefox already.
09:24
<@TheWatcher>
How about the signing option, is that possible?
09:24
< Moltare>
And it's a moot point since I could build the installer with the Mozilla framework attached and run it through the built-in XULRunner thingy
09:25
< Moltare>
I don't think it is, unless I missed something; I'd have to provide a certificate-serving database on the bath uni server, and I have no option to do that
09:26 * Reiver steals Moltare, feeds him Haskell for breakfast.
09:27
< Moltare>
om nom nom
09:27 * Reiver then compiles him.
09:27 * Moltare breaks horribly
09:28 * Reiver grumbles, goes bugfixing in the source code.
09:28
<@Reiver>
Mighty long ATATATATAT strings, here... I think we can get rid of those for a start.
09:29 * TheWatcher eyes Reiver
09:29
<@Reiver>
I want to debug my genome ;_;
09:30
< Moltare>
> Bad pun in lines 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, {9e99 skipped}
09:33 * Moltare flrrd to productiveness
10:13
<@MyCatVerbs>
McMartin: ((lambda (x) (x x)) (lambda (x) (begin (display 'Desu! ')(x x))))
11:06 Rhamphoryncus [~rhamph@Nightstar-7184.ed.shawcable.net] has quit [Quit: Rhamphoryncus]
14:13 gnolam [lenin@Nightstar-1382.A163.priv.bahnhof.se] has joined #Code
14:13 mode/#code [+o gnolam] by ChanServ
14:23
<@gnolam>
DO NOT WANT
14:27 * gnolam sighs and starts looking for another browser.
15:12 KBot [AnnoDomini@Nightstar-29625.neoplus.adsl.tpnet.pl] has joined #Code
15:14 AnnoDomini [~farkoff@Nightstar-29326.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
15:14 KarmaBot [AnnoDomini@Nightstar-29326.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
15:15 KBot is now known as KarmaBot
15:20 AnnoDomini [~farkoff@Nightstar-29625.neoplus.adsl.tpnet.pl] has joined #Code
15:20 mode/#code [+o AnnoDomini] by ChanServ
16:05 NSGuest-761 is now known as EvilDarkLord
16:38 Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code
16:39 mode/#code [+o Attilla] by ChanServ
17:19 Finale [c0cb88fd@Nightstar-14595.mibbit.com] has joined #code
17:19
< Finale>
know what hurts?
17:19
< Finale>
when a site about perl works on php.
17:20
< Moltare>
deeeleeesheeoooos irony
17:36
<@ToxicFrog>
Ok, Django is really slick.
17:36
<@ToxicFrog>
Also, I like the documentation.
17:36
<@ToxicFrog>
"Because the URL patterns are regular expressions, there really is no limit on what you can do with them. And there's no need to add URL cruft such as .php -- unless you have a sick sense of humor, in which case you can do something like this:
17:36
<@ToxicFrog>
(r'^polls/latest\.php$', 'mysite.polls.views.index'),"
17:36
<@ToxicFrog>
"But, don't do that. It's silly."
17:40 Derakon[AFK] is now known as Derakon
18:30 Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has quit [Ping Timeout]
18:31 Attilla [~The.Attil@Nightstar-9147.cdif.cable.ntl.com] has joined #code
18:31 mode/#code [+o Attilla] by ChanServ
18:34 * Derakon ponders his options with regards to what he should make after Fusillade.
18:35
<@Derakon>
There's Selene, which I know I could make without too much trouble, but am not hugely enthusiastic about.
18:35
<@Derakon>
There's Battlemage, which I could also probably make, but I'm worried that making a game that relies on networked multiplayer is a dicey proposition.
18:35
<@Derakon>
There's Jetblade, which I'd love to make, but I'm worried that it's too ambitious a project at this stage.
18:36
<@Derakon>
I'm kind of wondering if maybe I should do my own take on Spelunky -- randomly-generated platforming levels, that is.
18:38
<@Derakon>
The idea being that it'd be a good stepping-stone to Jetblade without requiring the massive asset and level design workload that Jetblade will.
18:38
< Moltare>
Work with me to make N/Spy-vs-Spy/DDR/Worms/Bowman-Dash
18:38
< Moltare>
>_>
18:38 * Derakon facepalms.
18:39
< Moltare>
:D
18:39
<@ToxicFrog>
"Why use a text-based template instead of an XML-based one (like Zope's TAL)? We wanted Django's template language to be usable for more than just XML/HTML templates. At World Online, we use it for e-mails, JavaScript and CSV. You can use the template language for any text-based format.
18:39
<@ToxicFrog>
Oh, and one more thing: Making humans edit XML is sadistic!"
18:40
<@Derakon>
Heh.
18:40
<@Derakon>
Of course, XML is text, just with some extra window dressing.
18:41 * TheWatcher eyes mol
18:41
< Moltare>
whaaat
18:41
<@TheWatcher>
why is it that, every time you mention that, the list of ///s sprouts different games? ;)
18:41
< Moltare>
It doesn't
18:42
< Moltare>
Sometimes I merely forget to include one in the output
18:43
<@TheWatcher>
mmhmm. I just noticed that 'worms' had slipped in there, is all ;)
18:43
< Moltare>
Physics engine and general look-and-feel of N, traps/landmines from Spy vs Spy, ninja rope from Worms, bow mechanics from Worms/Bowman Dash, and swordfighting subgame from the keyboard version of DDR
18:43
< Moltare>
:P
18:46
< Moltare>
(you know you waaaaant to)
18:52
<@Derakon>
I think this has the same problem that Battlemage does -- I'm leery of making a game that's dependent on multiplayer to be successful.
18:53 * ToxicFrog strangles this test server
18:54
<@ToxicFrog>
It seems to be caching old versions of settings.py
18:54
<@ToxicFrog>
And randomly choosing whether to use those or the version on disk
18:57
<@TheWatcher>
Dera: just out of interest, why is that?
18:57
<@TheWatcher>
higher critical mass for success, or something?
18:57
<@Derakon>
Yeah.
18:57
<@Derakon>
You need to have an existing player base to attract more players.
18:57 * TheWatcher nod
18:58
<@Derakon>
If you try three times to log on and play a game and every time there's nobody on the tracker, you're going to give up on the game pretty quickly.
19:15 * Derakon ponders design for what amounts to randomized Jetblade.
19:16
< EvilDarkLord>
Err, what's Jetblade?
19:16
<@Derakon>
(I still view this as simpler than normal Jetblade because I don't feel obligated to make 16 different tilesets and dozens of monsters and detailed level designs and so on).
19:16
<@Derakon>
Jetblade is my concept for a Metroid/Castlevania-style game.
19:17
<@Derakon>
Named such because the protagonist has a jetpack and armblades.
19:36 * Derakon envisions the Metroid map as a tree structure, with every branchpoint "locked" by a barrier that requires a special ability to pass.
19:38
<@Derakon>
Actually, a possibly-cyclic graph, to allow for loopbacks.
19:39
<@Derakon>
Mmm...start with a tree structure for now, actually.
19:40 Consul [~consul@Nightstar-29739.dsl.sfldmi.ameritech.net] has quit [Ping Timeout]
19:45
<@Derakon>
Something like this: http://derakon.dyndns.org/~chriswei/temp/gamegraph1.png
19:52 Consul [~consul@Nightstar-12789.dsl.sfldmi.ameritech.net] has joined #code
19:52 mode/#code [+o Consul] by ChanServ
19:54
<@Consul>
Great. Pidgin's getting kicked off of ICQ again.
19:56
< Moltare>
What, people will have to use real English instead?
19:56 Syloq [Syloq@Admin.Nightstar.Net] has joined #code
19:56 * gnolam guffaws.
19:57 Syloq is now known as Syloqs-AFH
20:04
< Tarinaky>
Is anyone here good at BASH?
20:05
< Tarinaky>
I need to trick a shell script into thinking I'm using Gnome (rather than KDE). I -think- the line that's important is " elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;" but I'm having trouble parsing it in my head.
20:06
<@MyCatVerbs>
That's checking to see if GNOME_DESKTOP_SESSION_ID is defined as something other than the empty string. In a somewhat archaic way, too.
20:07
<@MyCatVerbs>
So you could just "env GNOME_DESKTOP_SESSION_ID=pornography bash your_shell_script.sh". But that might break if it attempts to communicate with any of the Gnome daemons that it might expect to see running. Still, it can't possibly break too badly, right Bruce?
20:12 Tarinaky [~Tarinaky@88.83.110.ns-10776] has quit [Client exited]
20:13 Tarinaky [~Tarinaky@88.83.110.ns-10776] has joined #code
20:21
< Tarinaky>
MyCatVerbs: The problem is compounded slightly. The shell script isn't called directly by me.
20:22
< Tarinaky>
gnome-do invokes xdg-open to determine how it should open a file.
20:22
<@MyCatVerbs>
Set it earlier on. Before starting whatever program it is that starts whatever program it is that... by induction, starts the shell script.
20:22
< Tarinaky>
so "env $GNOME_DESKTOP_SESSION_ID = 0 gnome-do&" should work, yes?
20:24
<@Derakon>
Right, time to start working on procedural map generation~
20:24
< Tarinaky>
Because, it kindof doesn't >.>
20:25
<@TheWatcher>
Derakon: have fun
20:25
<@Derakon>
It should prove an interesting problem anyway, TW.
20:25
< Tarinaky>
Neither does "env $GNOME_DESKTOP_SESSION_ID=headdesk xdg-open ~"
20:25
<@TheWatcher>
Indeed!
20:25
<@Derakon>
Much like implementing BulletML was for Fusillade.
20:25
< Tarinaky>
Oh wait...
20:25 * Tarinaky facepalms.
20:25
< Tarinaky>
I'm an idiot.
20:25
<@Derakon>
Hee.
20:25
< Tarinaky>
THanks for the help.
20:25
<@Derakon>
Welcome to the club.
20:26
< Tarinaky>
All that work just to get a gnome app to use gnome-open rather than try to be compatible -_-
20:27
<@MyCatVerbs>
Tarinaky: glad you got it working, elsewise I'd have to think about it more, or be bugged all day. =)
21:44
<@Derakon>
Mental note: adding lists in Python does list append, not addition of elements in the lists. Whoops.
22:04 Reiv [~82d94c4d@Nightstar-29731.dsl.in-addr.zen.co.uk] has joined #Code
22:10
<@ToxicFrog>
zipwith (+) lista listb?
22:15
<@Derakon>
I was doing a "while location[0] < endlocation[0]: do something; location += delta".
22:16
< Reiv>
Whoops. SMRT
22:17
< Reiv>
capitalize :: Char -> Char capitalize x | x == head['a'..'z'] = chr ((ord x - 32)) | otherwise = x
22:17
< Reiv>
Turns out that head[listgoeshere] returns the first item of the list and /only/ the first item of the list. >_>
22:18
< Reiv>
So the code works for 'a' -> 'A', but that's it. *coff*
22:18
<@Derakon>
Hee.
22:18 * Reiv goes hunting for the syntax to check 'if x is /in this list/'...
22:20
< Reiv>
Not 'in'. Pity. >_>
22:31 * Reiv siiigh. Cannot find the syntax; suspects it is not as easy as he had hoped.
22:44
< Reiv>
Bah-HAH
22:45
< Reiv>
'any' does precisely what was needed.
22:45
< Reiv>
any (==x) ['a'..'z'] returns true if x == anything in the list.
22:45 * Reiv glee
22:46
< Reiv>
I think I like Haskell. It runs like my brain does. >_>
22:47
<@McMartin>
What, is everyone picking up Haskell again at once here?
22:47
<@Derakon>
I thought it was just Reiver...
22:48
<@TheWatcher>
I'm certainly not >.>
22:49 * McMartin dove in recently too.
22:50
<@McMartin>
And one of the IF guys has been trying to extend a decompiler that was written in Haskell and having a hard time of it.
22:50
<@McMartin>
It is called Mrifk.
22:50
<@McMartin>
"BY THE SURLY BEARD OF MRIFK, GRIGNR BOWS TO NO MAN"
23:01 * Derakon blarghs, tries to figure out why blocks on the right and bottom edges of the screen are not drawing.
23:18 You're now known as TheWatcher[T-2]
23:25 You're now known as TheWatcher[zZzZ]
23:26
< Reiv>
McM: I'm rather enjoying it, truth be told
23:27
< Reiv>
though at the immediate moment I am struggling with the basic syntax of lists
23:27
< Reiv>
Or at least, some basic quirk of syntax /involving/ lists.
23:27
<@McMartin>
It's the same lists as LISP and ML.
23:27
<@McMartin>
As in, singly-linked from the head
23:27
< Reiv>
Neither of which I've ever used~
23:27
<@McMartin>
C++ and Java use double-linked.
23:28
<@McMartin>
Or vectors, which are random-access.
23:29
<@TheWatcher[zZzZ]>
McM: I note that AFAIK REiv has had no grounding in the underlying mechanics of ADTs
23:29
<@TheWatcher[zZzZ]>
(having skipped the module that covered it)
23:30
< Reiv>
If this was Java I... actually, I'd probably not use a list at all, and if I did it'd be several lines of code.
23:30
<@ToxicFrog>
If this was Java you'd use an ArrayList<Foo> or something.
23:30
< Reiv>
Yeah.
23:31
< Reiv>
I'm trying to make a list of booleans that performs an OR on the lot of them.
23:32
<@ToxicFrog>
You want fold, I think
23:32
<@McMartin>
So, first, the list, and then foldl (&&) lst?
23:32
< Reiv>
S'what I'm doin'. :)
23:32
<@McMartin>
Or whatever boolean and is in Haskell
23:32
< Reiv>
or_list :: [Bool] -> Bool or_list [] = False or_list [b:bs] = foldr b || [bs]
23:33
<@ToxicFrog>
Can't you just say:
23:33
<@McMartin>
Why not just foldr False || [b]?
23:33
< Reiv>
The last line is what falls down. I'm just rechecking the syntax.
23:33
<@McMartin>
It may be (||)
23:33
<@ToxicFrog>
fold (||) [b]
23:33
<@ToxicFrog>
And yeah, it's (||)
23:33
<@McMartin>
Er
23:33
< Reiv>
... you can do that?
23:33
<@McMartin>
The list is x
23:33
<@ToxicFrog>
Er, sorry
23:33
<@McMartin>
or_list x = foldr False (||) x
23:34 Tarinaky [~Tarinaky@88.83.110.ns-10776] has quit [Client exited]
23:34
<@ToxicFrog>
Hmm. It might not actually have plain fold
23:34
<@ToxicFrog>
In which case, what McM just said
23:34
< Reiv>
That's nifty.
23:34
< Reiv>
So what does it /mean/?
23:34 * Reiv is determined, for once, to Get It on the fundamentals.
23:35
<@McMartin>
What it really means is "or_list is a specialization of a more general library method."
23:35
<@ToxicFrog>
http://www.haskell.org/haskellwiki/Fold
23:35
<@McMartin>
If you want the actual fundamentals you should be doing it with nothing but recursion and the || operator
23:35
< Reiv>
(I get (||) is passing OR as a function to be used. More the "False, OR, listgoeshere" bit.)
23:35
< Moltare>
oh, toss
23:35
<@ToxicFrog>
That link explains it quite well.
23:35
<@McMartin>
Fold's arguments are "basis value", "operator", and "values".
23:35
< Moltare>
Anyone have handy hints on convincing Youtube I live in America?
23:36 Tarinaky [~Tarinaky@88.83.110.ns-10776] has joined #code
23:36
<@McMartin>
foldr vs. foldl deal with parenthesization, which is irrelevant here because || associates
23:36
< Reiv>
... Aaaah. Shiny.
23:36
< Moltare>
The UK operators have just gone through with their NO MUSIC VIDEOS OFF YOUTUBE FOR YOU FILTHY ENGLISH TYPES
23:37
< Reiv>
So fold is (Default) (Thing to do to each item in list) (target list)
23:37
<@ToxicFrog>
s/default/start/
23:37
< Reiv>
Er, right.
23:38
<@McMartin>
So, to compute the product of a list, start should be 1; for the sum, it should be 0
23:38
<@ToxicFrog>
fold val fn list basically does "val = fn(val, head list)" until it runs out of list
23:38
<@ToxicFrog>
(iteratively, anyways)
23:38
<@ToxicFrog>
And the wiki page discusses the recursive approach.
23:38
<@McMartin>
eah
23:39
<@McMartin>
I'd say that for a grasp of the fundamentals of lists as opposed to fold, you need to basically reimplement fold by hand.
23:39
<@McMartin>
Or a specialized version like sum or or_list.
23:39 * ToxicFrog nods
23:39
<@ToxicFrog>
Or do the first chapter of SICP~
23:39
<@McMartin>
That reminds me, I should read through the tutorial of implementing Scheme in Haskell.
23:40
< Reiv>
OK!
23:40
<@McMartin>
If only because it might even cover the Mysteries.
23:40
< Reiv>
... why would you implement Scheme in Haskell? Or is this one of those academic teaches-you-a-lot things?
23:40
<@McMartin>
(What language experience do you have, Reiv?)
23:40
<@McMartin>
The latter, primarily
23:40 * Reiv coughs. Fark all, alas.
23:41
<@McMartin>
For practical reasons, it would let you re-use Haskell's memory allocators, garbage collector, and possibly also exploit its lazy evaluator
23:41
< Reiv>
I used to know C, VB & Java (In which I was taught the concepts of OO programming) with reasonable proficiency.
23:41
<@McMartin>
THe latter of which I won't get into other than to say it's the reason that the only usable Perl 6 implementation is written in Haskell.
23:41
<@McMartin>
OK, that's enough.
23:41
<@McMartin>
LISP/ML/Haskell lists are made of a structure that looks like this:
23:41
< Moltare>
ha, gottit
23:41
<@McMartin>
struct node<T> { T val; struct node<T> *next; }
23:42
< Moltare>
orrr not
23:42
< Reiv>
I am, unfortunately, horrifically out of practice with the syntax of all three to the point where I essentially need to relearn them to be able to actually /use/ the bastards.
23:42
<@ToxicFrog>
Linked lists, basically; which I believe we discussed earlier.
23:42
< Moltare>
damn
23:42
<@McMartin>
So you have a node pointer that is the front of the list, and then you can keep following the "next" pointer until you hit NULL.
23:42
<@ToxicFrog>
(how did that go, incidentally?)
23:42
<@McMartin>
The question was whether you could read it.
23:43
<@McMartin>
(The above was C++, but it doesn't use anything in C++ that isn't also in Java or C)
23:43
<@ToxicFrog>
(C has templates now?)
23:43
<@McMartin>
(Java has Generics, which are like templates but compilation is guaranteed to finish and it doesn't produce 100 copies of the same function in the resulting binary)
23:43
< Reiv>
The only bit of that I would query is the *next; syntax.
23:43
<@McMartin>
* means "pointer to that type, not a type itself"
23:44
<@ToxicFrog>
That's C/++; the Java would be something like:
23:44
<@ToxicFrog>
class Node<T> { T val; Node<T> next; }
23:44
<@ToxicFrog>
Since java is implicitly indirect.
23:44
<@McMartin>
Right.
23:44
<@McMartin>
In Java, the empty list is a null node, "head" is an accessor for "val", and "tail" is an accessor for "next".
23:45
<@ToxicFrog>
(C/++ distinguishes between 'Node foo', which is an actual Node, right here, part of the object, and 'Node * foo', which is a pointer to a Node somewhere else)
23:45
<@ToxicFrog>
(Java only does the latter and drops the * entirely)
23:45
< Reiv>
Remind me what <T> does in Java? I... sort of kind of remember. >_>
23:45
<@ToxicFrog>
Generics.
23:45
<@McMartin>
<T> means "*insert type here*"
23:46
<@McMartin>
So Node<int> would give you a list of ints, Node<String> a list of Strings, etc.
23:46
<@ToxicFrog>
Node<T> will in practice be used as, say, new Node<String> to create a Node that holds Strings
23:46
<@ToxicFrog>
...get out of my heeeead
23:46
< Reiv>
Ah! Yes.
23:46
<@McMartin>
(It also autoconverts between types like int and the container objects like Integer behind your back, so you don't have to.)
23:46
<@McMartin>
(In this, it catches up a little with C# which does all this better and more generically)
23:47
< Reiv>
Okay, that clicks. I'm still a little used to seeing next; used as a command rather than a decleration.
23:48
<@McMartin>
nextNode, then if you will~
23:48
< Reiv>
... Oh, right
23:48
< Reiv>
Holds a value, and a ... ahahaha, oh, I get it
23:49
<@McMartin>
The * there is because in C or C++ it would try to hold the actual value and thus would be declaring a variable of infinite size.
23:49
<@McMartin>
In Java, there are only references.
23:49
< Reiv>
Holds a value, and a link to the next one in the string, because you just declared it to exist.
23:50 * Reiv was getting hung up on the details of the syntax. Thanks!
23:51
< Reiv>
Okay, so if a list is that little thing there, then... hm. [x:xs] in Haskell is just pulling out x from [xs], which then recurses because xs is [x:xs], so pulls out x, etc et al?
23:51
<@McMartin>
Nnnot quite.
23:51
< Reiv>
Oh.
23:51
<@McMartin>
That's a wacky Haskell/ML thing.
23:51 * Derakon eyes his isSurrounded function, which isn't behaving itself.
23:51
<@Derakon>
http://paste.ubuntu.com/129571/
23:51
<@McMartin>
Try this on for size:
23:52
<@McMartin>
or_list x = if null x then False else (head x) || (or_list (tail x))
23:52
<@Derakon>
...oh, wait, my conditional's wrong. Go me.
23:52
<@McMartin>
Does that read clearer to you?
23:52
<@McMartin>
(I may have blown parenthesis; function binding precedence in Haskell throws me off all the time)
23:53
< Reiv>
(It's cool, I'm not that hot on parentheses yet either)
23:53
< Reiv>
It does indeed make sense.
23:54
< Reiv>
And it's not actually altering the list x as it does that, correct?
23:54
<@McMartin>
Nope.
23:55
<@McMartin>
Nothing ever modifies *anything* in Haskell.
23:55
<@McMartin>
Though there's some syntactic additions that make it look like it does, but only under special circumstances.
23:55
< Reiv>
... yeah, it's not in scope. So if it's null it's false, but if it empties, it just /returns/ false, but it's already evaluated everything higher up the recursion anyway.
23:57
<@McMartin>
In Haskell, [] and False are not the same thing.
23:57
<@McMartin>
(Unlike LISP)
23:58
<@McMartin>
null is a function in Haskell that returns True if and only if its argument is []
23:58
<@McMartin>
Now, what you were seeing before was a pattern-matching declartaion.
23:58
<@McMartin>
Take factorial.
23:58
<@McMartin>
Here's factorial in the classic form:
23:58
<@McMartin>
f x = if x < 2 then 1 else x * f (x-1)
23:58
<@McMartin>
Right?
23:59
<@McMartin>
Here's the other way of defining it.
23:59
<@McMartin>
f 0 = 1
23:59
<@McMartin>
f x = x * f (x-1)
23:59
<@McMartin>
Upon seeing a call to f, it will go through the possibilities in declaration order, looking for something that matches.
--- Log closed Wed Mar 11 00:00:07 2009
code logs -> 2009 -> Tue, 10 Mar 2009< code.20090309.log - code.20090311.log >