Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 372 373 [374] 375 376 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 903725 times)

Kicior

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5595 on: March 19, 2014, 12:06:20 pm »

Yep I know my code is shit :P

(105,1)Fatal:syntax error ";" expected but UNTIL found
Code: [Select]
var
plik,odp:textfile;
l,i,jeden,dwa,trzy,cztery,piec,szesc,siedem,osiem,dziewiec,zero:integer;
jedenb,dwab,trzyb,czteryb,piecb,szescb,siedemb,osiemb,dziewiecb,zerob:integer;
j,d,t,c,p,sz,s,o,dz,z:boolean;
a,b:string;


begin

assign(plik,'C:\Users\3E\Desktop\Dane do pr_A2\dane.txt');
assign(odp,'C:\Users\3E\Desktop\Dane do pr_A2\odp.txt');

repeat
begin

jeden:=0;
dwa:=0;
trzy:=0;
cztery:=0;
piec:=0;
szesc:=0;
siedem:=0;
osiem:=0;
dziewiec:=0;

jedenb:=0;
dwab:=0;
trzyb:=0;
czteryb:=0;
piecb:=0;
szescb:=0;
siedemb:=0;
osiemb:=0;
dziewiecb:=0;

read(a);
read(b);

l:=length(a);
i:=1;

while i<l+1 do
        begin
        case a[i] of
        '0':zero:=zero+1;
        '1':jeden:=jeden+1;
        '2':dwa:=dwa+1;
        '3':trzy:=trzy+1;
        '4':cztery:=cztery+1;
        '5':piec:=piec+1;
        '6':szesc:=szesc+1;
        '7':siedem:=siedem+1;
        '8':osiem:=osiem+1;
        '9':dziewiec:=dziewiec+1;
        end;
        i:=i+1;
end;

i:=1;
l:=length(b);

while i<l+1 do
        begin
        case b[i] of
       '0':zerob:=zerob+1;
       '1':jedenb:=jedenb+1;
       '2':dwab:=dwab+1;
       '3':trzyb:=trzyb+1;
       '4':czteryb:=czteryb+1;
       '5':piecb:=piecb+1;
       '6':szescb:=szescb+1;
       '7':siedemb:=siedemb+1;
       '8':osiemb:=osiemb+1;
       '9':dziewiecb:=dziewiecb+1;
        end;
        i:=i+1;
        end;

if zero=zerob then z:=true;
if  jeden=jedenb then j:=true;
if dwa=dwab then d:=true;
if trzy=trzyb then t:=true;
if cztery=czteryb then c:=true;
if piec=piecb then p:=true;
if szesc=szescb then sz:=true;
if siedem=siedemb then s:=true;
if osiem=osiemb then  o:=true;
if dziewiec=dziewiecb then  d:=true;



if z and j and d and t and c and p and sz and s and o and d then
begin
append(odp);
writeln(a,b,' tak');
close(odp);
 end
else begin
 append(odp);
  writeln(a,b,' nie ');
close(odp);
end;

//this is the 105th line// until EOF;
end.

My guess is I forgot to put end; somewhere but I can't figure it out.
Halp anyone?
Logged
and slippedy sloppidy doo everything is made of fuck

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5596 on: March 19, 2014, 12:17:34 pm »

Are you opposed to consistent indenting for any particular reason? o_O

It would that a LOT easier to figure out...
Logged

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5597 on: March 19, 2014, 12:23:49 pm »

At start you have
begin
assign
assign
begin
repeat

Then only one end at the end and I can't find the repeat...until finalizer

Looks like you have a begin more and a until less. Pascal is sooooo confusing to talk about :P

Why did you get the number like that instead of an array of size 10?
« Last Edit: March 19, 2014, 12:30:03 pm by LoSboccacc »
Logged

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5598 on: March 19, 2014, 09:59:31 pm »

ugh, jQuery is annoying to learn. Its not helped by the fact that most examples use all the annoying shortcuts.

Code: [Select]
$(function(){

});

Is much less clear than

Code: (javascript) [Select]
jQuery(document).ready(function(){

});

I understand why you would have shortcuts like this, but it makes more sense to me to use the more verbose version for example pieces of code.
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5599 on: March 19, 2014, 10:25:45 pm »

ugh, jQuery is annoying to learn. Its not helped by the fact that most examples use all the annoying shortcuts.

Code: [Select]
$(function(){

});

Is much less clear than

Code: (javascript) [Select]
jQuery(document).ready(function(){

});

I understand why you would have shortcuts like this, but it makes more sense to me to use the more verbose version for example pieces of code.

In general, I agree, but there's something to be said for teaching the common idioms.

And with javascript in particular, minimization is an issue; in this case, the idiomatic form saves a lot of bytes. <voice type="sing-song">Make good habits early~!</voice>
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5600 on: March 19, 2014, 10:55:06 pm »

But shouldn't you write source code fully and have a minimizer shorten the production code? @_@
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5601 on: March 19, 2014, 10:57:36 pm »

In general, I agree, but there's something to be said for teaching the common idioms.

And with javascript in particular, minimization is an issue; in this case, the idiomatic form saves a lot of bytes. <voice type="sing-song">Make good habits early~!</voice>

ergh, It would have helped some of these websites had explained the "common" idioms used.

I also dont see the benefit of making the javascript harder to read just to save a few bytes when automatic minimisers can do a far better job anyway.

EDIT: what Skyrunner said.
« Last Edit: March 19, 2014, 11:06:02 pm by alexandertnt »
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5602 on: March 19, 2014, 11:48:41 pm »

In general I agree, but with jQuery it's so common to use $ instead of jQuery that a lot of people probably don't even realize you can use jQuery instead.  It's also pretty nice to type $ instead of jQuery when you have to write a lot of code with it.

Having said that, I've never seen the notation of just tossing a function inside of $() and expecting it to behave like $(document).ready().  I really don't like that and do prefer the more verbose option.  It's quite possible to write unreadable JavaScript code when using jQuery.
Logged
Through pain, I find wisdom.

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5603 on: March 19, 2014, 11:58:24 pm »

But shouldn't you write source code fully and have a minimizer shorten the production code? @_@
(I should probably note that I am far from an expert on Javascript/minimization.)

Well, yes. TBH this idiom is probably more Laziness than anything else. Though jQuery may pre-date the popularization of Javascript minimizers (don't know, to lazy to attempt to confirm), in which case the shortcuts make a lot more sense, especially the $ = jQuery bit.

A NINJA ATTACKS!

In general I agree, but with jQuery it's so common to use $ instead of jQuery that a lot of people probably don't even realize you can use jQuery instead.  It's also pretty nice to type $ instead of jQuery when you have to write a lot of code with it.

This. Very this.

Having said that, I've never seen the notation of just tossing a function inside of $() and expecting it to behave like $(document).ready().  I really don't like that and do prefer the more verbose option.

It is an odd, arbitrary alias. But given that most jQuery manipulations depend on the DOM being fully loaded, it mostly makes sense is you squint and don't think about it too much.

It's quite possible to write unreadable JavaScript code when using jQuery.
FTFY

Related: Just remembered this gem of a site: wtfjs.com

EDIT: I don't know why I felt the need to address every piece of your post Telgin. It's late and I'm starting to get tired.
« Last Edit: March 19, 2014, 11:59:58 pm by SolarShado »
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

BlindKitty

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5604 on: March 20, 2014, 12:36:44 pm »

I've learned what little I know about jQuery from codecademy.com (very basic tutorials of Python, Ruby, JS, jQuery, HTML, CSS and PHP, nicely organized - if you don't know anything about any of those langs and want to learn something, it is a good place to start IMO), and I have indeed failed to realize that $ sign is an alias for anything. Later I stumbled upon such use, and still I don't understand why on Earth anybody would use jQuery instead of $. :P
Logged
My little roguelike craft-centered game thread. Check it out.

GENERATION 10: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5605 on: March 20, 2014, 12:46:46 pm »

Because $ might conflict and renaming it works but it's doubly confusing
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5606 on: March 20, 2014, 02:08:02 pm »

My antipathy for symbols in code is pretty high.

This is why I don't much like Ruby and feel sorry for everyone who ever had to write in APL.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5607 on: March 20, 2014, 02:13:26 pm »

My antipathy for symbols in code is pretty high.

This is why I don't much like Ruby and feel sorry for everyone who ever had to write in APL.

Wait, what is wrong with symbols?

Also, yeah, I always use jQuery instead of $, after getting burned on too many products that already used $ for something else, I prefer to just avoid the potential for conflict nowadays.
Logged

da_nang

  • Bay Watcher
  • Argonian Overlord
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5608 on: March 20, 2014, 02:22:34 pm »

My antipathy for symbols in code is pretty high.

This is why I don't much like Ruby and feel sorry for everyone who ever had to write in APL.

Wait, what is wrong with symbols?

Also, yeah, I always use jQuery instead of $, after getting burned on too many products that already used $ for something else, I prefer to just avoid the potential for conflict nowadays.
Eh, symbols (as in non-alphanumeric characters) are fine as long as their meanings are clear and they're not overused so as to retain readability. Case in point: Brainfuck.
« Last Edit: March 20, 2014, 02:24:23 pm by da_nang »
Logged
"Deliver yesterday, code today, think tomorrow."
Ceterum censeo Unionem Europaeam esse delendam.
Future supplanter of humanity.

BlindKitty

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5609 on: March 20, 2014, 02:49:17 pm »

Well, right, now I see the point. The conflict with other things, I mean. Never really dug deep into the jQuery, JavaScript and the like (I'm only programming in C# and - recently - I'm picking up a little bash scripting, with a bit of Python mixed in probably), and I never stumbled into anything like such conflicts. That said, I don't really have problem with symbols (actually, I think that we could use enriching the keyboard layout, to include non-ASCII symbols in larger numbers, so those could be used with more ease; also, going up from ASCII with some backwards compatibility would be a nice thing, too, but with both I may overlook some considerations that make it impossible/impractical) in code, it's just what da_nang said: don't overuse it. It's on those rare occasions when Mythbusters motto* isn't really cutting it.

*If it is worth doing, it's worth overdoing!
Logged
My little roguelike craft-centered game thread. Check it out.

GENERATION 10: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
Pages: 1 ... 372 373 [374] 375 376 ... 796