Programming @4-ch

Programming @4-ch

Be it HTML, C++, Java or whatever language you prefer, programming is what we do best around this board.
Markup languages are also fine around here, as with all the "not so real" languages of Shell script, CSS, and other various third party scripting languages.
  • We are sick of language discrimination, more so the PHP/Java bashers. There will be little tolerance of blatant and repetitive insults. You are still welcome to bring forward a sensible, insult-free argument regarding a certain topic at the appropriate time and place for it.
  • Please use WakabaMark or the appropriate HTML tags (with HTML enabled, of course) to format your code.
Rules · 規則
基本的には英語の使用を強く希望します。ただ日本語板の場合は日本語か英語。
Board look: Blue Moon Buun Futaba Headline Mercury Pseud0ch Toothpaste

Pros and Cons of Schemes (33)

1 Name: #!/usr/bin/anonymous : 2009-03-23 12:39 ID:xCfhRJI2

I have recently gotten into a lot of Scheme programming but I am wondering which implementation I should use. Which implementations are considered the "major" ones and what are the various pros and cons of each? I'm running on an Ubuntu Linux box and right now I have PLT Scheme and Guile installed. Are there other implementations I should consider? Ultimately I would like to be able to create GUI applications, and any cross-platform support would be very nice. PLT Scheme seems to have a compiler, and if an implementation lets me create native binaries (for my Windows-using friends) then that's also a bonus.

24 Name: #!/usr/bin/anonymous : 2009-06-13 23:35 ID:N8xpq412

>>23
Hmmm, it seems that you are without a doubt a raging homosexual. One in ten people they say. Certainly the odds are not against it.

25 Name: #!/usr/bin/anonymous : 2009-06-14 00:50 ID:Heaven

>>24

> Hmmm, it seems that you are without a doubt a raging homosexual.
How can it seem without doubt, and what does that mean?

> One in ten people they say. Certainly the odds are not against it.
Not any more (or any less) than they are for you (if *) or anyone else who(*) is a part of the demographic used in the statistics, no.

Regardless, I'm going to let you reconsider but I'll also let you know that I'd rather talk about _programming_ here, than anything else. Quite often the likes of you are dealt via the reporting system. Perhaps you should appreciate that I'm taking you seriously, shall I say, lest I be misunderstood, that this is not a threat, but shall we say, it points out my willingness to co-operate with you.

26 Name: dmpk2k!hinhT6kz2E : 2009-06-14 01:17 ID:Heaven

Please don't feed trolls.

27 Name: #!/usr/bin/anonymous : 2009-06-14 01:34 ID:Heaven

>>26
I agree that getting involved in discussions with trolls is most boring and repetitive, I believe that this individual is not a troll, but rather someone who was "insulted" by my correction. Before you scold me for my beliefs, wouldn't you agree that you believe as well as I do on the matter; because you believe he's a troll, and I believe he's not one.

You'll also note that all my replies insofar to this thread have been 'sage' posts, namely >>20,23,25 and the one you read now.

28 Name: #!/usr/bin/anonymous : 2009-06-14 04:00 ID:N8xpq412

>>25,27
Contrary to what most homosexuals believe, the phrase "it seems" does not have in it implicit connotations of doubt. And it does seem that for the particular demographic of you, yourself, and probably your boyfriend, the odds are 1 in 1. And certainly I appreciate your opinion of me as not being a troll.

29 Name: #!/usr/bin/anonymous : 2009-06-14 06:33 ID:Heaven

>>22-25,27-28
same person.

30 Name: #!/usr/bin/anonymous : 2009-06-15 18:41 ID:fHEDrNWC

>>29
Person who is usually slowest in the uptake in conversations.

31 Name: #!/usr/bin/anonymous : 2009-06-17 13:26 ID:Heaven

>>1-30
Conversation which has been derailed; not that there were tracks in the first place.

32 Name: #!/usr/bin/anonymous : 2009-07-01 18:19 ID:9D+8w4kS

Place full of retards.

33 Name: jc : 2009-07-02 01:51 ID:NTc4GQe6

gcj (gnu compile java) is a good option. It supports Swing and compiles natively on windows and Linux. While easy to program the binaries are (still) large. Most have Java these days - if that is the case, a JAR distribution is small. You can run them with gij (gnu intrepreit Java).

Ruby is great too .. you can same some coding there. not sure about the gui for this though. I prefer coding html and just using the browser. You'll have to be a Javascript guru in the long run to make this work right.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

Pardon me, just need to upload some code (6)

1 Post deleted.

2 Name: trap.py : 2009-06-20 01:05 ID:Lgw4LUKj

Oh, God damn it, nevermind...

3 Name: #!/usr/bin/anonymous : 2009-06-20 01:23 ID:Heaven

reported

4 Name: #!/usr/bin/anonymous : 2009-06-20 04:17 ID:Heaven

http://www.pastebin.com is a wonderful site.

5 Name: DDoM!RqyGtg4Mtw : 2009-06-27 00:06 ID:Heaven

10 BAN
20 GOTO 10

6 Name: #!/usr/bin/anonymous : 2009-07-01 18:17 ID:5h6lDdK/

bump for wasn't this permasaged a while ago?

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

Thoughts on C++? (47)

1 Name: #!/usr/bin/anonymous : 2009-03-14 13:11 ID:RoT3Fvkt

What do you all think about C++? I'm just starting off on programming and was going to use C++ as my first. When it comes to programming, I know little to nothing about the technical, in-depth details. In some places (mainly /prog/), I've heard C++ isn't all that great and isn't worth learning. But again, what do you all think?

38 Name: #!/usr/bin/anonymous : 2009-06-25 23:49 ID:ifw+GRvP

>>35

>XNA

Xna is intended more for independent games, often from one man development teams.
Most large studios will either write their own engines, or license middleware, like Unreal 3, or something similar.

39 Name: #!/usr/bin/anonymous : 2009-06-28 01:01 ID:nq1SY2TA

C++ was my third language after C64 Basic and Pascal, respectively. While it is a very powerful language, it does come with a lot of responsibility on the programmer's part. In part, that is why people are slowly moving away from it. It is still a de-facto standard in games and operating systems, but that will slowly change as well (google Microsoft Singularity and Microsoft Midori). Also, its syntax can be a bit verbose and the standard libs are a bit archaic.
I have also learned C, Java, JSP (basically Java for webapps), C#, Perl, and Ruby. Out of all these languages I like Ruby the most. It feels very natural to program in it once you get used to its syntax and the fact that it is dynamic. I'll give you a (contrived) comparison/example between C++ and Ruby

C++

for(int i = 1; i <= 10; i++)
{

cout << i << " ";

};

Post too long. Click to view the whole post or the thread page.

40 Name: #!/usr/bin/anonymous : 2009-06-28 10:33 ID:Heaven

>>39
c♯ (which you apparently don't know as well as you think you do):

foreach(var i in Enumerable.Range(1, 10)) Console.Write("{0} ", i);

prolog:

numlist(1, 10, L), forall(member(N, L), format("~d ", N)).

haskell:

mapM_ (putStr . flip shows " ") [1..10]

factor:

10 [ 1 + pprint " " write ] each

41 Name: #!/usr/bin/anonymous : 2009-06-29 21:49 ID:nq1SY2TA

>>40

Dude, no need to brag. We all know you da pro. I wasn't giving an example of each/foreach and I was doing a C++ vs Ruby comparison, but I guess you are too lazy to read the post. Plus, I said the example is contrived.

Anyways, you brought up a good point with these examples. Only factor comes somewhat close in simplicity/succinctness to the Ruby example.

42 Name: 41 : 2009-06-29 21:53 ID:nq1SY2TA

Oh yeah, I forgot to add 'each' version of Ruby:

(1..10).to_a.each { |n| print "#{n} " }

or

(1..10).to_a.each do |n|
print "#{n} "
end

43 Name: #!/usr/bin/anonymous : 2009-06-30 00:45 ID:Heaven

(dotimes (n 10)
(print n))

If you have implemented the map0-n utility, then you can write it as:

(map0-n #'print 10)

44 Name: #!/usr/bin/anonymous : 2009-06-30 08:52 ID:Heaven

>>41
the c♯ one was just to point out that you were wrong when you wrote

> (with exception of Perl) they are all more or less similar to C++.

all four examples of those examples are simpler than your ruby example, and two of them are more succinct. you don't seem to realize that neither "simple" nor "succinct" are directly related to the number of characters. for example, for i in 1 2 3; do echo $i; done is a lot simpler than :(){:|:&};:, which is much shorter.
and the prolog one isn't as simple and succinct as it could be:

forall(between(1, 10, N), format("~d ", N)).

45 Name: 41 : 2009-07-01 01:01 ID:nq1SY2TA

>>41

We can spend a whole day debating the meanings of simplicity and succinctness. I realize that your views are not open for interpretation. Thus, there's no room for debate.

>>(with exception of Perl) they are all more or less similar to C++.

What I meant by this is that other languages I numbered (Java and C#) are syntactically quite similar to C++, which is no surprise considering that they share same (read: C) ancestry. It is my view that C#'s version of foreach follows quite different and, arguably, more verbose syntactical patterns when compared to Ruby. I am sorry it sounded like an attack to your favorite language that C# obviously is. It wasn't my intention at all. On the contrary, I prefer it to Java.

I do not agree that all four examples are simpler (at least, in my view of simplicity). I do agree that factor example is shorter (i.e., less verbose) but not necessarily any more obvious than the Ruby version is. That said, it might very well be a matter of being used to one favorite language. It is, therefore, hard for any programmer (not only me) to be entirely unbiased when it comes to rating programming languages.

Post too long. Click to view the whole post or the thread page.

46 Name: dmpk2k!hinhT6kz2E : 2009-07-01 04:05 ID:Heaven

The Ruby example does not need a to_a().

Here's a slightly different implementation, similar to Factor's:

10.times { |n| print n+1, " " }

47 Name: #!/usr/bin/anonymous : 2009-07-01 06:37 ID:Heaven

> Ruby code is actually quite clean and you can always omit line noise by simply doing a do...end construct instead and you can also omit ().

for >>44's prolog code, you only need to know forall, between, and format.
for your ruby code, you need to know .., .to_a, .each, do ... end, |...|, and print.
"line noise" has nothing to do with it.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

A Problem in Logic (26)

1 Name: #!/usr/bin/anonymous : 2008-05-04 03:29 ID:MuJs/AX1

I need some help with a simple problem involving the basic logical operators: AND, OR, and NOT, along with the relational operator EQUAL TO, and truth values TRUE and FALSE.

Let's assume that we have a function tD() that tests whether 3 integers are all different. So, tD( 1, 2, 2 ) will return FALSE, and tD( 6, 6, 6 ) will return TRUE.

Now, my problem is to define a function the uses the above to determine whether or not 4 integers are equal. Let's call it

bool fE( a, b, c, d )

defined completely in terms of

bool tD( a, b, c) 

and the aforementioned operators.

you can write in any code you prefer.

17 Name: #!/usr/bin/anonymous : 2008-05-04 23:59 ID:Heaven

>>16

> Therefore, your function fE(1, 2, 1, 1) will return TRUE. But is it true that they are all equal? NO.

It would not, with my definition (or at least what I understood from your definition).
But fine, with your definition of tD(), yes, it wouldn't be correct.

I have another question, do you consider TRUE and FALSE as integers? (1 and 0). It would make things easier in solving this

18 Name: #!/usr/bin/anonymous : 2008-05-05 00:10 ID:Heaven

>>17
Your definition doesn't really make sense to me:

(((a & b & c) | b | c) == a)

Since a, b, and c are integers, and | is a logical operator,

(((a & b & c) | b | c) 

will always evaluate to TRUE unless a, b, and c are all 0.

here is what tD() would look like in C:

bool tD( int a, int b, int c )
{
return !( (a == b) || (b == c) || (a == c) )
}

19 Name: #!/usr/bin/anonymous : 2008-05-05 00:21 ID:BJTy114F

>>14
Oh, I though tD returned true when all three are not the same. After reading >>16, I don't think there is an actual solution to this unless you know beforehand that a,b,c,d are all not a specific value. If you know that, then you can do

frE(a,b,c,d) = not( thrD(a,b,k) or thrD(a,c,k) or ...[rest of the pairs])

Otherwise, I don't see any solution.

20 Name: #!/usr/bin/anonymous : 2008-05-05 00:24 ID:Heaven

>>18
My definition used the binary operators | and & and not the logical && and ||. (my mistake)
Also, my definition of tD() checks if just two are unequal.

>>19
I see a solution, if true and false are numbers 1 and 0.

21 Name: #!/usr/bin/anonymous : 2008-05-05 00:30 ID:BJTy114F

>>20
Care to show it then?

22 Name: #!/usr/bin/anonymous : 2008-05-05 00:40 ID:Heaven

>>12

So why are you making up utterly pointless homework problems? Just get a job in academia already if that's what you want to do.

Also, your problem is unsolvable as stated.

tD(a,a,a)==tD(a,a,b)==tD(a,b,a)==tD(b,a,a)==FALSE

However, fE(a,a,a,a) != fE(a,a,a,b), but as fE can only be defined in terms of the above expressions, which all have the same value, fE(a,a,a,a) will be equal to fE(a,a,a,b) no matter how it is defined.

23 Name: #!/usr/bin/anonymous : 2008-05-06 04:39 ID:Heaven

>>1

bool fE(a, b, c, d){
return tD(0, 1, 2) && a == b && b == c && c == d;
}

24 Name: #!/usr/bin/anonymous : 2008-05-06 05:14 ID:Heaven

>>23
YOU JUST WON THE GAME!

25 Name: #!/usr/bin/anonymous : 2008-05-06 22:59 ID:Heaven

>>22
take a chill pill dude.
GREAT GOING KID!

26 Name: #!/usr/bin/anonymous : 2009-06-15 16:00 ID:1O5xs7G4

lol the hilarious memories

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

ADA (13)

1 Name: #!/usr/bin/anonymous : 2009-04-13 01:09 ID:j2x8qNwp

Anyone programmed in ADA? If so what's your experiences.

4 Name: #!/usr/bin/anonymous : 2009-05-10 01:37 ID:R2LvJ8Tv

there was nothing particularly good or bad about it, its useable but i would never use it for anything since i can never see a reason.

5 Name: #!/usr/bin/anonymous : 2009-05-25 00:30 ID:l6Iv8T7t

The only experience I have with Ada is from the examples at rosettacode.org. The feelings I have are that Ada is an over-the-toply complex, verbose and boring language.

Oh well. Someone prove me wrong. Maybe Ada can serve some purpose?

6 Name: #!/usr/bin/anonymous : 2009-05-25 02:37 ID:fnz5bop0

>>5
That IS its purpose.

7 Name: #!/usr/bin/anonymous : 2009-05-25 04:25 ID:D6plFpSS

>>6
So why would anyone use it instead of Java, which is a more popular over-the-toply complex, verbose and boring language?

8 Name: dmpk2k!hinhT6kz2E : 2009-05-25 06:41 ID:Heaven

There are some interesting uses, like SPARKAda.

If you're writing software that lives will depend on, it should be criminal to not use something like it. Apparently a lot of medical equipment doesn't, which creeps me out.

9 Name: #!/usr/bin/anonymous : 2009-05-28 02:50 ID:Heaven

>>8
what really creeps me out is seeing a windows BSOD on medical equipment.

10 Name: #!/usr/bin/anonymous : 2009-06-05 12:49 ID:3YDqkyhu

>>7
Maybe because of the standardized compilers

11 Name: #!/usr/bin/anonymous : 2009-06-10 16:00 ID:Z29U4G1D

Code a missile's CPU.

That's about it.

12 Name: #!/usr/bin/anonymous : 2009-06-10 21:23 ID:Heaven

>>11
I don't think there's any ada compilers for playstation 2.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

Good 2D Game Engines (C++) (42)

1 Name: #!/usr/bin/anonymous : 2008-07-09 06:20 ID:80dioBYP

I'm looking for some good 2d game engines to create games using C++ i know there are plenty(ish) about but i want to know which ones are good, and if you know of any books that can guide me through creating 2d games for beginners let me know.

I was reading a book that uses llamaworks2d game engine but it actually doesn't work -_- and it got recalled, so now im stuck for where to go next.

Thanks

33 Name: #!/usr/bin/anonymous : 2008-07-22 15:19 ID:Heaven

>>32
what a fucking idiot.
"Listen" here is not literal, it asks for attention.
"Read, OP just wants someplace to start" is plain wrong.

34 Name: #!/usr/bin/anonymous : 2008-07-22 18:01 ID:Heaven

>>33 That's the Joke </McBain>

35 Name: #!/usr/bin/anonymous : 2008-07-23 00:42 ID:Heaven

Laughing time is ovah.

36 Name: #!/usr/bin/anonymous : 2008-07-27 09:14 ID:JJ7h/mzX

>>26

>You must be thinking of Allegro which does require such nonsense.

Lol wut?

37 Name: #!/usr/bin/anonymous : 2008-08-10 19:09 ID:ZAZM3PEY

I found OpenGL easier to use than SDL or Allegro. So what if its a 3D api, it can just as easily be used for 2D. If you use GLUT and youve got a little C++ experience under your belt, the tutorials around the net should see you through.

38 Name: #!/usr/bin/anonymous : 2008-08-10 23:50 ID:Heaven

>>37

Even though it can be used for 2D, 2d-cards can't accelerate GL, which means running your 2d-only game on lower-end graphics cards really sucks a lot more than it would otherwise have to.

I really like my matrox dualhead board- it has the fastest 2d and xv support out of any of the graphics cards (including when compared to 3d boards) I've tried. It doesn't have any gl/3d support however at all.

39 Name: #!/usr/bin/anonymous : 2008-11-16 18:50 ID:chc84A7q

jobby

40 Name: syphod : 2009-05-31 17:12 ID:Nv1v4low

You can look for SFML, it's new but pretty good... and very fast :P

41 Name: syphod : 2009-05-31 17:14 ID:Nv1v4low

and who use a 2d cards these day ?
Just try fml, simple & fast ;)

42 Name: #!/usr/bin/anonymous : 2009-06-15 18:14 ID:Heaven

>>24
I think he was reffering to how often it checks for keyboard input

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

WHY IS /CODE/ SO GODDAMN SLOW (24, permasaged)

1 Name: LUNIS TARBALLS : 2008-11-26 19:44 ID:/V7Fqiv5

that's it i'm going to gb2/prog/

15 Name: #!/usr/bin/anonymous : 2009-03-26 01:25 ID:ny+/fSa+

>>14
but me is you and you are me

16 Name: #!/usr/bin/anonymous : 2009-03-26 06:30 ID:Heaven

>>15
Do you sometimes wish you were you?

17 Name: #!/usr/bin/anonymous : 2009-05-15 22:40 ID:3g4EVREf

CLS
GOTO START

18 Name: #!/usr/bin/anonymous : 2009-05-16 01:23 ID:Heaven

>>17
Hello. I am ELIZA. How can I help you?

19 Name: #!/usr/bin/anonymous : 2009-05-17 23:24 ID:Heaven

sage

20 Name: #!/usr/bin/anonymous : 2009-05-18 23:34 ID:Heaven

>>19
Please go on.

21 Name: #!/usr/bin/anonymous : 2009-05-22 06:01 ID:Heaven

1 PRINT HELLO HOW ARE YOU?
2 SAGE
3 GOTO 1

22 Name: #!/usr/bin/anonymous : 2009-05-24 03:47 ID:vySMzEY1

You yust dont know how to write fast code

23 Name: #!/usr/bin/anonymous : 2009-05-24 13:23 ID:Heaven

sage

24 Name: #!/usr/bin/anonymous : 2009-05-25 04:25 ID:Heaven

Requesting a permasage for this thread, please.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

Agile software development (13)

1 Name: #!/usr/bin/anonymous : 2008-10-28 23:01 ID:uIzuJk7z

I found out a day or two ago I have to read all these papers and case studies at my job about Agile software development (mostly with SCRUM) and I was wondering what the programming board thinks of the Agile method.I think its not any different then when I was programming on my own just more focus on working programs, less documentation and customer satisfaction. Sounds like a cluster fuck to me.

Here's some info for people who don't know:
http://agilemanifesto.org/
http://en.wikipedia.org/wiki/Agile_software_development
http://en.wikipedia.org/wiki/SCRUM

4 Name: #!/usr/bin/anonymous : 2008-10-31 01:40 ID:Heaven

>Agile software development

It's like all those shitty Web 2.0 sites that display BETA in their logos like it's some kind of badge of pride.

Perpetual Beta = You're doing it wrong!

5 Name: #!/usr/bin/anonymous : 2008-10-31 12:09 ID:Heaven

>>3
those god damn links in >>1's post have nothing to do with programming, they're about "business".

6 Name: #!/usr/bin/anonymous : 2008-11-01 02:26 ID:Heaven

>>5 the business of programming

7 Name: #!/usr/bin/anonymous : 2008-11-01 11:15 ID:Heaven

>>6
you can make a business out of anything, that doesn't mean it's relevant to it.

8 Name: #!/usr/bin/anonymous : 2008-11-02 21:09 ID:Heaven

>>7 yes it does

9 Name: JavaMan : 2008-12-07 04:41 ID:8eVJjPV9

So, back on topic...

I have studied Aagile methodologies and tried to apply them in the workplace where the development typically followed the waterfall model [http://en.wikipedia.org/wiki/Waterfall_model]). I have found that many of the Agile concepts only work if you have highly skilled developers that can write self-documenting code.

Following the DRY (Don't Repeat Yourself [http://en.wikipedia.org/wiki/Don't_repeat_yourself]) principle, means programmers should avoid 'double duty' whenever possible. Often documentation is analogous to the code that expresses it ... which often seems like wasted effort. I believe Agile is an extreme form of the DRY principle.

IMO, the waterfall model is better suited to development teams that are not as skilled at software development. Unfortunately in the real world at most development shops, not every programmer has the skills and discipline needed to work effectively in a strict Agile development environment.

JavaMan out!

10 Name: JavaMan : 2008-12-07 04:42 ID:8eVJjPV9

JavaMan can's spelll...

11 Name: #!/usr/bin/anonymous : 2008-12-11 03:17 ID:ApQ8wcpk

Fuck Fowler and the rest, man. The good parts of Agile are obvious, and easy to apply. Learning these should take you about 15-30 minutes. The rest of it is pure cockvomiting bullshit, a lame attempt to spin a few decent ideas into another [b][u][i]ENTERPRISE BEST PRACTICES METHODOLOGY[/i][/u][/b] and sell a lot of books.

12 Name: #!/usr/bin/anonymous : 2008-12-13 00:54 ID:Heaven

>>11
    [b][u][i]ENTERPRISE BEST PRACTICES METHODOLOGY[/i][/u][/b]


    VERY NICE USAGE OF BEST PRACTICES METHODOLOGY

13 Name: #!/usr/bin/anonymous : 2009-05-09 20:07 ID:+A+xdGmw

Only have experience with RAD here. It was a horrible experience. No one had the full picture what was going on. A clusterfuck trying to integrate the different layers since no one knew how the different parts should communicate with each others. Since there were minimal planning everyone had their own picture how the system would look like resulting in nothing being delivered.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

polygonal stuff in HTML/CSS (3)

1 Name: #!/usr/bin/anonymous : 2009-05-05 02:27 ID:+aWmjee0

I dabble occasionally in HTML/CSS for my own amusement, though I'm certainly not an expert. and there's two particular and slightly related things i'm trying to work out.

first off i'm trying to do one of those corner banner things (like the "make poverty history" ones everyone had a while back) so i have the thing absolutely positioned in the top right, the image itself is a gif with transparency and i'm using an image map (which seems a little..oldschool to me, but still) to link only the actual banner area of the image.

but is there any way to make the stuff visible beneath the transparent areas of the image behave as it otherwise would if the image wasn't present? text selectable, links clickable and so forth. currently it just acts as if the whole rectangle is an image. ideally i'd like to only define the "image" as the actual polygonal shape that makes up the visible area. if that makes any sense.

secondly, and relatedly, is there any way to define a non-rectangular block to contain text? like |______\ shaped for the particular thing i'm trying to do.

so yeah. Basically i'm wondering if it's possible to have shit that isn't rectangular.

2 Name: #!/usr/bin/anonymous : 2009-05-05 04:53 ID:rfM3RZzD

http://alastairc.ac/2007/02/dissecting-css-polygons/

Take a look at this...it's complicated, but possible...

3 Name: #!/usr/bin/anonymous : 2009-05-06 03:41 ID:Heaven

use svg. it's a lot easier.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

[LISP] programs (11)

1 Name: #!/usr/bin/anonymous : 2009-04-14 14:18 ID:VD9IJuBK

Here's an image viewer I recently wrote, in common lisp.
You'll need lispbuilder-sdl and lispbuilder-sdl-image for this, also com.gigamonkeys.pathnames. All the source of PCL here, http://gigamonkeys.com/book/practicals-1.0.3.tar.gz

esc escapes the viewer
space views the next image, backspace the previous. If there's no other image to show, the program exits.
You can invoke VIEW with both a single image to view or a directory to be searched recursively and show the images.
Example, (view "/path/to/pictures"), (view "/path/to/pictures/foo.jpg")

(defparameter *supported-formats* '(".bmp" ".jpg" ".png"))
(defun list-to-array (list)
(and (listp list)
(make-array (list (list-length list))
:initial-contents list)))
(defun valid-image-p (p)
Post too long. Click to view the whole post or the thread page.

2 Name: dmpk2k!hinhT6kz2E : 2009-04-15 20:45 ID:Heaven

You'll have a hard time convincing people to install SBCL. :o

3 Name: #!/usr/bin/anonymous : 2009-04-18 22:44 ID:rqqdcJqO

>>2
Which people? I've got it installed already, as do several people I know.

4 Name: #!/usr/bin/anonymous : 2009-04-19 05:16 ID:Heaven

> Which people?

people who don't fantasize about oatmeal with toenail clippings in it.

5 Name: dmpk2k!hinhT6kz2E : 2009-04-19 08:01 ID:Heaven

I feel a bit bad about >>2. I'm actually happy to see some variety in code.

Common Lisp spooks me due to its sheer size though. If only Scheme had a useful set of mature libraries.

Unrelated aside: it seems Factor has first-class macros. How does that work?

6 Name: Zach Beane : 2009-04-20 12:07 ID:SikWUUwZ

(coerce list 'vector) is a shorter way to do list-to-array.

The one-letter variable names are hard to follow.

7 Name: OP : 2009-04-21 02:32 ID:VPLCSXs5

>>6
Thanks, I'm still at the first learning steps. COERCE seems to be the abstraction I was in need but unaware of.

As for the one-letter names, I agree. It's how I write code because I don't want to waste time thinking for a name when the code to-be-written is at hand. When the code portion is done, I take time to rename the symbols, but in this particular instance I was so excited from my first lisp program that I shared the source omitting this step.

8 Name: #!/usr/bin/anonymous : 2009-04-24 17:01 ID:0LdgJMma

OP again

This is a simple drawing program.
You can either draw in a white canvas or on top of an image of your choice. Use (draw) or (draw "/path/to/foo.png") for example.

It has 7 colors, red, orange, yellow, green, blue, indigo, violet. You can change color with spacebar, save your drawing with s (which will either save to file lisp.bmp if you were drawing on a white canvas else /path/to/foo.png.bmp) and exit with escape.

(defparameter *supported-formats* '(BMP JPG PNG))
(defparameter *color-pallete*
(circular-list
(mapcar (lambda (x) (apply #'sdl:color x))
'((:r #16rff :g #16r00 :b #16r00) ; red
(:r #16rff :g #16ra5 :b #16r00) ; orange
(:r #16rff :g #16rff :b #16r00) ; yellow
Post too long. Click to view the whole post or the thread page.

9 Name: #!/usr/bin/anonymous : 2009-04-24 17:04 ID:0LdgJMma

*))
(sdl:update-display))))))

These were missing from the source I posted. Append them to what's been posted already.

10 Name: Zach Beane : 2009-04-27 15:30 ID:SikWUUwZ

CL has special syntax for bits, octal, and hex, and #r is the escape hatch for other bases. So instead of #16rFF, I'd write #xFF. You could also write it as #b11111111 or #o377 but that would be silly...

11 Name: #!/usr/bin/anonymous : 2009-04-27 17:29 ID:eloEXY0+

>>10
Ah, that's better.

There's something else I realized, the implementation of circular-list can be simplified:

(defun circular-list (lst)
(let ((lst (copy-list lst)))
(if lst (nconc lst lst))))

and if the WHEN-BIND macro is available, (on lisp), it could be written even sorter.

Your website has a lot of lisp code, cool. :-) Once I feel more comfortable with my lisp knowledge and I've read some more chapters from the book I mentioned before, I think I'm going to start reading others' code, so your website will come handy.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification:

New thread

Title:
Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: