Wednesday, November 28th, 2007 12:05 pm

hmm

Started work on functions and arrays these last two weeks. Question.

Strings = a complex array?

A lot of class now is spent less with notes and more with short, simple programs as illustration, which I cannot emphasize enough how awesome that it, though it does reinforce my inability to do a damned flowchart or IPO. Anyway. I was looking at strings, since they have their very own include to be added as a data type--was that written so that there wouldn't necessarily be arrays for stuff like entire paragraphs? And how are those created?

I'm curious. I've been playing with functions a lot to see how they shorten a program, and the arrays feel very--interesting, yes, but also interestingly *useful*. Though I'm not sure how yet.

Seriously, I only have two weeks left, and I'm already missing this class a lot. I really wish they had a Christmas short semester.

Sadly, we are skipping two dimensional arrays. It is depressing.

You know, eventually, I have got to think of something more interesting to say.
soul_cake_duck: (happy - bea_lost)

From: [personal profile] soul_cake_duck Date: 2007-11-28 06:26 pm (UTC)
Arrays. I have bad memories of my time with them (and Java in general). But they could be useful...

2D Arrays are sort of like an array within an array. I think strings were slightly different to a complex array. But I'm pretty sure all the knowledge I had of Java evaporated after my exam, so I cant be certain!

From: [identity profile] seperis.livejournal.com Date: 2007-11-28 10:09 pm (UTC)
*looks at book* That's still, so far, a better explanation than the book on teh subject. Hmm.
astolat: lady of shalott weaving in black and white (Default)

From: [personal profile] astolat Date: 2007-11-28 06:26 pm (UTC)
Strings are represented differently in different languages -- in ordinary C, any string (no matter how long) is just an array of characters terminated with the null character '\0', which leads to lots of awesomeness especially when you forget to terminate properly. In most modern languages, strings are either a class or a built-in type all their own, so the internal implementation is hidden from you most of the time, and you don't have to think of it as anything other than a string. :)
ext_1541: (Default)

From: [identity profile] summertea.livejournal.com Date: 2007-11-28 08:04 pm (UTC)
AHAHA THAT NULL CHAR. i have had so much hilarity when i forgot to add that stupid thing on at the end.

From: [identity profile] seperis.livejournal.com Date: 2007-11-28 10:10 pm (UTC)
*twitch* stupid '\n'. that has caused many sad moments
akacat: A cute cat holding a computer mice by the cord. (Catmoran logo Santa'd)

Warning: geek-out ahead

From: [personal profile] akacat Date: 2007-11-28 06:32 pm (UTC)
Strings = a complex array?

Depends on the language, and if it's involved, the database. And the two may not deal with strings the same way. Afaik, these are the ways a string can be stored:

- an array (either exposed to the developer or not).
- a fixed length piece of data that consists of one character after another.
- a piece of data of length n that begins with a character count.
- a piece of data of unspecified length that begins with a special start character and ends with a special end character.

And depending on the language, the array may be stored in any of the last three ways, or as a linked list. (But I don't think they teach linked lists anymore.)

It doesn't hurt to think of them as arrays, most languages allow you to work with the characters as if the string was an array.

Re: Warning: geek-out ahead

From: [identity profile] seperis.livejournal.com Date: 2007-11-28 10:20 pm (UTC)
C++. I was thinking about it since I was trying to get my professor to explain how to change strings so if they didn't capitalize the frist word the program would, and he was like, wait for arrays!

This does conveniently explain why soem programs have character limits when entering names. I think.

Strings???

From: [identity profile] maxinemayer.livejournal.com Date: 2007-11-28 06:39 pm (UTC)
By the end of your post I had the vague feeling you might maybe perhaps be talking about computer programming (as opposed to my original thought that it was string theory therefore physics that you were going on about). The two previous comments make me think it IS computer programming. To say I'm illiterate in computer languages is really to make it sound as if I could somehow BECOME literate, if I tried. That is SO not the case. Nevertheless, I stand in awe of computer fluent people (heck, I stand in awe of the telephone, cordless or otherwise - I still haven't "gotten over" Atlantis-sized awe of pretty much any kind of machinery (how the heck does it WORK, for crying out loud!). Computers are next to God to me - incomprehensible wondrous "beings" for which my gratitude is boundless and about which my ignorance cannot be conveyed. I'm not exaggerating, truly. Anyway, those who "get" computers on any level beyond read, write, save, print, automatically earn my reverence and gratitude: without them, my life would be so much poorer, the wheel fades into insignificance in comparison.... Hope you find more ways to feed your mind on this subject, other classes, other books and teachers. We need your expertise but more, we need your love for learning.

Re: Strings???

From: [identity profile] seperis.livejournal.com Date: 2007-11-28 10:32 pm (UTC)
*g* It is deeply, deeply fun.
ext_3058: (Default)

From: [identity profile] deadlychameleon.livejournal.com Date: 2007-11-28 07:50 pm (UTC)
Strings in C/C++ are arrays, which are a higher level form of stack. Strings are arrays of characters that terminate in a /0 null operator. Characters are, of course, just ASCII numerical values 0-256, I believe. Upper and lower case characters are set numerical values separate from each other.

http://en.wikipedia.org/wiki/C_string

From: [identity profile] seperis.livejournal.com Date: 2007-11-28 07:52 pm (UTC)
That's what I suspected when strings are treated as singular units like numbers and not as individual characters, esp with the transform command able to capitalize or lowercase all or none.

Fascinating. *mulls*
ext_3058: (Default)

From: [identity profile] deadlychameleon.livejournal.com Date: 2007-11-28 08:01 pm (UTC)
glad you like arrays, you're going to use them a lot, most likely.

Stacks are a lower level form of array that don't have the niceties built in.
If I recall correctly, strings started out as a separately defined character class because of storage issues way back when in the dark ages of the beginning of computer programming. (Back when storage capacity was an issue and programs were long, laborious constructs written in programming languages that were one step up from Assembler.) Strings were defined & stored in a different section of memory, and took up less space than the data representing numbers, cause you didn't have to do add/subtract/etc to them.

This is my hazy remembering from the dawn of time.

Seriously, I got my Computer Science degree in 1983 -- I started programming in ...huh...1976? Maybe? (oh, in the essence of full disclosure, I stopped in 1989 when I went back to school to study Psych. But I was systems level programmer for a large corporation for 5 years after graduation, and I have been enjoying reading about your glee at your classes. You are the first person to tempt me to go back & retake a class or two)

/mybrainhurtsfromthinkingaboutprogramming...thunk/

*g* I get *ridiculously* excited about it. I just love this class. I ove how its organized and writing out what I learn so it clicks and just--gah. Happy.
PS. When I saw your response, I remember how giddy I was with flowcharts....
umm,err, then I remembered that it was the plastic ruler-like flow chart drawing aids that I adored.

I'm pretty sure I never, ever wrote a flowchart before a program through my entire college career. (i'd do the program first, then make a flowchart to hand in).

I'm pretty sure I never did a flowchart during my entire RL career, either. (unless I had to explain a programming concept to somebody).

Ironically, I've written pseudo-flowcharts to design systems in non-programming environments quite often (they are especially helpful to chart typical crisis call scenarios).

My favorite part of college? Really really obscure programming languages. (My main language was FORTRAN, which unless you loaded it with comments to explain what was happening was onoy understandable to people who knew the language).

But my favorite of all languages -- APL. (literally stood for "A Programming Language" and was all symbols. Not normal alphanumeric characters, but symbols. Heh).

Oh oh -- and LISp. (aka: Lots of Irritating Parentheses). I actually programmed in LISp for the last year of my career, which is why, to this very day, I have to close off any/all embedded parentheses (when I make asides within asides (which I love to do (cause it's fun fun fun))).


:-D
Do you know the programming language brainfuck (http://en.wikipedia.org/wiki/Brainfuck)? So much fun, so little use :)

From: [identity profile] bluevsgrey.livejournal.com Date: 2007-11-29 01:29 am (UTC)
Strings = a complex array?

I see in the comments you seem to be conflicting answers. Are you talking about regular strings or C-strings? Because in the case of c-strings this is definitely the case as c-strings are character arrays. However, on the regular data type string I am not so sure as to how they are actually allocated in memory, but my instinct is to say no that strings are probably a class.

was that written so that there wouldn't necessarily be arrays for stuff like entire paragraphs? And how are those created?

I don't know but that is a very interesting question. I am assuming it was written because c-strings are actually pointers* that point to a character array and therefore all normal operations(=,+,-, >, <) don't work as you would expect them to. I am assuming that what is written in the include is what fixes this to where they perform as expected.

*Have you gotten to pointers yet? They let you dynamically allocate the size of the array based of something else(user input, size, ect). So cool.

I am sure you have learned this but the first rule of arrays is: for loops are your best friend. (for(int i = 0; i > size; i++){})

From: [identity profile] purelyironic.livejournal.com Date: 2007-11-29 06:48 am (UTC)
(for(int i = 0; i > size; i++){}

There's a small typo :)

It should be for (int i=0; i < size; i++) {}

Profile

seperis: (Default)
seperis

Tags

Quotes

  • If you don't send me feedback, I will sob uncontrollably for hours on end, until finally, in a fit of depression, I slash my wrists and bleed out on the bathroom floor. My death will be on your heads. Murderers
    . -- Unknown, on feedback
    BTS List
  • That's why he goes bad, you know -- all the good people hit him on the head or try to shoot him and constantly mistrust him, while there's this vast cohort of minions saying, We wouldn't hurt you, Lex, and we'll give you power and greatness and oh so much sex...
    Wow. That was scary. Lex is like Jesus in the desert.
    -- pricklyelf, on why Lex goes bad
    LJ
  • Obi-Wan has a sort of desperate, pathetic patience in this movie. You can just see it in his eyes: "My padawan is a psychopath, and no one will believe me; I'm barely keeping him under control and expect to wake up any night now to find him standing over my bed with a knife!"
    -- Teague, reviewing "Star Wars: Attack of the Clones"
    LJ
  • Beth: god, why do i have so many beads?
    Jenn: Because you are an addict.
    Jenn: There are twelve step programs for this.
    Beth: i dunno they'd work, might have to go straight for the electroshock.
    Jenn: I'm not sure that helps with bead addiction.
    Beth: i was thinking more to demagnitize my credit card.
    -- hwmitzy and seperis, on bead addiction
    AIM, 12/24/2003
  • I could rape a goat and it will DIE PRETTIER than they write.
    -- anonymous, on terrible writing
    AIM, 2/17/2004
  • In medical billing there is a diagnosis code for someone who commits suicide by sea anenemoe.
    -- silverkyst, on wtf
    AIM, 3/25/2004
  • Anonymous: sorry. i just wanted to tell you how much i liked you. i'd like to take this to a higher level if you're willing
    Eleveninches: By higher level I hope you mean email.
    -- eleveninches and anonymous, on things that are disturbing
    LJ, 4/2/2004
  • silverkyst: I need to not be taking molecular genetics.
    silverkyst: though, as a sidenote, I did learn how to eviscerate a fruit fly larvae by pulling it's mouth out by it's mouthparts today.
    silverkyst: I'm just nowhere near competent in the subject material to be taking it.
    Jenn: I'd like to thank you for that image.
    -- silverkyst and seperis, on more wtf
    AIM, 1/25/2005
  • You know, if obi-wan had just disciplined the boy *properly* we wouldn't be having these problems. Can't you just see yoda? "Take him in hand, you must. The true Force, you must show him."
    -- Issaro, on spanking Anakin in his formative years
    LJ, 3/15/2005
  • Aside from the fact that one person should never go near another with a penis, a bottle of body wash, and a hopeful expression...
    -- Summerfling, on shower sex
    LJ, 7/22/2005
  • It's weird, after you get used to the affection you get from a rabbit, it's like any other BDSM relationship. Only without the sex and hot chicks in leather corsets wielding floggers. You'll grow to like it.
    -- revelininsanity, on my relationship with my rabbit
    LJ, 2/7/2006
  • Smudged upon the near horizon, lapine shadows in the mist. Like a doomsday vision from Watership Down, the bunny intervention approaches.
    -- cpt_untouchable, on my addition of The Fourth Bunny
    LJ, 4/13/2006
  • Rule 3. Chemistry is kind of like bondage. Some people like it, some people like reading about or watching other people doing it, and a large number of people's reaction to actually doing the serious stuff is to recoil in horror.
    -- deadlychameleon, on class
    LJ, 9/1/2007
  • If imitation is the sincerest form of flattery, then Fan Fiction is John Cusack standing outside your house with a boombox.
    -- JRDSkinner, on fanfiction
    Twitter
  • I will unashamedly and unapologetically celebrate the joy and the warmth and the creativity of a community of people sharing something positive and beautiful and connective and if you don’t like it you are most welcome to very fuck off.
    -- Michael Sheen, on Good Omens fanfic
    Twitter
    , 6/19/2019
  • Adding for Mastodon.
    -- Jenn, traceback
    Fosstodon
    , 11/6/2022

Credit

November 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2022
Page generated Mar. 15th, 2026 11:42 am
Powered by Dreamwidth Studios