Questions tagged [gnu-smalltalk]

GNU Smalltalk is a free implementation of the Smalltalk-80 language. It runs on most POSIX compatible operating systems (including GNU/Linux, of course), as well as under Windows. Smalltalk is a dynamic object-oriented language, well-versed to scripting tasks.

GNU Smalltalk is a free implementation of the Smalltalk-80 language. It runs on most POSIX compatible operating systems (including GNU/Linux, of course), as well as under Windows. Smalltalk is a dynamic object-oriented language, well-versed to scripting tasks.

115 questions
1
vote
1 answer

Object: true error: did not understand #value while anding booleans together

I'm attempting to solve AoC problem 12 part 2 in Smalltalk. The specific aren't super relevant, but here's the relevant portion of a single-dimensional version of the model I'm using for the problem: Object subclass: Moon [ | X XX Xin | init…
badp
  • 11,409
  • 3
  • 61
  • 89
1
vote
2 answers

Can I extend built-in String class with my methods

I find that there is no built-in trim (strip) method to remove leading and trailing spaces from strings in the built-in String class. I want to extend it with my functions. Is it possible? Using example here, I tried following code: String extend [ …
rnso
  • 23,686
  • 25
  • 112
  • 234
1
vote
1 answer

Class and methods to trim string not even starting

I am trying to create a class with string trimming functions: Object subclass: Trimmer [ trimleading: str [ |ch ret| ch := (str first: 1). "get first character" ret := str. "make a copy of sent…
rnso
  • 23,686
  • 25
  • 112
  • 234
1
vote
1 answer

Why file path string is not splitting

I want to find files in a directory, then split the pathname and print each part of path on a separate line: (Directory working: '.') allFilesMatching: '*.st' do: [ :ff | (ff name) findTokens: '/' "Linux separator" "splitOn: '/' …
rnso
  • 23,686
  • 25
  • 112
  • 234
1
vote
1 answer

Object: Directory error: did not understand #name

Following simple code to list files in a directory is from here: (Directory name: '.') allFilesMatching: '*.st' do: [ :f | (f name) displayNl ] However, it is not working and giving following error: $ gst mysrc.st Object: Directory error: did…
rnso
  • 23,686
  • 25
  • 112
  • 234
1
vote
2 answers

How do I invoke blocks from subclasses in superclass method?

I think my problem is mostly syntax but it might be my overall understanding of class hierarchy. Basically it's a Deck class with an array filled with Card objects, Card is a subclass of Deck, so Deck should be able to use Card's blocks and methods,…
ALW
  • 11
  • 2
1
vote
1 answer

How to just get key only on GNU Smalltalk?

I am currently using sortedCollection that stores dictionary of character (key) and number of occurrence for that character (value). When iterating through sortedCollection, how do I access the key value only? e.g. [que last notNil] whileTrue: [ …
selfPointer
  • 339
  • 1
  • 2
  • 12
1
vote
1 answer

How do we send a canvas image data as an attachment to a server on Pharo?

How do we send or upload a data file to a server on Pharo. I saw some example of sending file from a directory on the machine. It works fine. ZnClient new url: MyUrl; uploadEntityfrom: FileLocator home /Path to the file; put In my case I…
ludo
  • 543
  • 3
  • 14
1
vote
1 answer

Efficency of assign-and-compare in the same statement in Smalltalk

A previous SO question raised the issue about which idiom is better in time of execution efficency terms: [ (var := exp) > 0 ] whileTrue: [ ... ] versus [ var := exp. var > 0 ] whileTrue: [ ... ] Intuitively it seems the first form could be…
1
vote
1 answer

Understanding GNU Smalltalk Closure

The following piece of code is giving the error error: did not understand '#generality' pqueue := SortedCollection new. freqtable keysAndValuesDo: [:key :value | (value notNil and: [value > 0]) ifTrue: [ |newvalue| newvalue := Leaf…
patzi
  • 353
  • 4
  • 13
1
vote
1 answer

Using extended classes in gst (GNU smalltalk)?

This is a bit of a follow-up question to this one. Say I've managed to extend the Integer class with a new method 'square'. Now I want to use it. Calling the new method from within the file is easy: Integer extend [ square [ | r | …
Mossmyr
  • 909
  • 2
  • 10
  • 26
1
vote
2 answers

Bernoulli-number method wrong for input > 1

I'm trying to implement a method that returns the n:th bernoulli number, like so: Object subclass: #Bernoulli. Bernoulli class extend [ "****************************************************** * Psuedo code for bernoulli method I'm…
Mossmyr
  • 909
  • 2
  • 10
  • 26
1
vote
3 answers

Can not call "function" in GNU Smalltalk

I want to define block and call it in this way: add := [ :a :b | ^(a+b). ]. n := add value: 1 value: 2. But when I try it, I get an error: $ gst 3.1.st Object: 3 error: return from a dead method…
DmitriyM
  • 125
  • 2
  • 9
1
vote
1 answer

How to concatenate a string in a do block?

I'm trying to go though a array and add characters from that array to another object. The problem is I keep getting a error "Instances of character are not indexable". However when I run tag := tag,char outside of the do block then it works. |data…
MikeC
  • 255
  • 4
  • 16
1
vote
1 answer

How to get name of superclass according to class in smalltalk

I know how to get a metaclass of a class in SMALLTALK (with class message ). But how do i get the SuperClass of a class (or get the SuperClass of an instance of some class )?
2Big2BeSmall
  • 1,348
  • 3
  • 20
  • 40